Jump to content

Copy web page content to SQL database?


tinfanide

Recommended Posts

If a webpage has the following structure,

<ul><li>point 1</li><li>point 2</li><li>point 3</li></ul>

how can I copy the content (in the form of texts) to a SQL database PROGRAMMATICALLY?For example, transfer "point 1" to the first row of a SQL table and "point 2" and "point 3" accordingly.Does it involve work of writing a program to analyse the content of the webpage before uploading the content into the database using server-side languages?

Edited by Tin
Link to comment
Share on other sites

Im new to programming SQL, but isnt SQL only about grabbing querys and pulling information from tables?I dont know about inserting information.
well, how would the information get in there in the first place? SQL is for storing and retrieving information from databases.http://www.w3schools.../sql_insert.asphttp://www.w3schools.../sql_insert.asp to the OP, it would have to be done programmatically by a server side script to get the content, parse its structure, prepare it to be used in a query format, and then ultimately make the query. How to do so, all depends on the complexity of the markup coming in. Edited by thescientist
Link to comment
Share on other sites

Sorry, I don't quite understand what ya guys're discussing. But I go search a bit and find two solutions to achieve what I want: file_get_contentsBut this only copies the HTML contents. I cannot break it down and take the unordered list contents away. simple HTML dom parserIt seems I can make use of the DOM structure to take away what I want but I do not know what to do (after receiving an error), including the php page on my server. Could anyone tell me how to use the simple HTML dom parser?It returns errors when I just include the page in my PHP script after putting the PHP page (simple_HTML_dom_parser page) on the server. Many thanks.

Link to comment
Share on other sites

post your code and error please.

Link to comment
Share on other sites

Im new to programming SQL, but isnt SQL only about grabbing querys and pulling information from tables? I dont know about inserting information.
How do you suppose the data in the tables gets there in the first place? The data manipulation language part of SQL includes SELECT, INSERT, UPDATE, and DELETE. You're talking about SELECT only.
Link to comment
Share on other sites

And now I'm thinking of making use of the Simple HTML Dom parser. Basically I want to copy the Dom structure of the page:http://lifelearning.xtreemhost.com/simple.html and show part of the structure in this page:http://lifelearning.xtreemhost.com/board.php

<?phprequire_once 'simple_html_dom.php';$html = new simple_html_dom();$html->load_file('http://lifelearning.xtreemhost.com/simple.html');echo $html->find('div[id]');?>

But the board PHP page shows the error:

Warning: file_get_contents() [function.file-get-contents]: http:// wrapper is disabled in the server configuration by allow_url_fopen=0 in /home/vol13/xtreemhost.com/xth_9595110/htdocs/simple_html_dom.php on line 1081Warning: file_get_contents(http://lifelearning.xtreemhost.com/simple.html) [function.file-get-contents]: failed to open stream: no suitable wrapper could be found in /home/vol13/xtreemhost.com/xth_9595110/htdocs/simple_html_dom.php on line 1081Fatal error: Call to a member function find() on a non-object in /home/vol13/xtreemhost.com/xth_9595110/htdocs/simple_html_dom.php on line 1113
And I followed the tutorial on http://www.youtube.com/watch?v=zTJk0_2p8tc&list=PLE1036D2604E505E7&index=17&feature=plpp_video
Link to comment
Share on other sites

it's right there in the first error message

http:// wrapper is disabled in the server configuration by allow_url_fopen
If you are on a shared host, they might have it off by default. You can ask to see if they can enable it for you.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...