Help!php Posted March 5, 2012 Share Posted March 5, 2012 I usually run scrape on a website and get information and the new ones are usually added automatically but its not adding a new information. I am wondering whethere I have an issue with my code. I usually run scrape through the sitemap. $qry = "CREATE TABLE sitemap ( id varchar(30), price decimal(6,2), url varchar( 1024 ) )"; // Create the table mysql_query ( $qry, $con ); $numSitemapPages = 350; $html = new simple_html_dom(); if($_ECHO) echo "START: Fetching site map...<br />"; for( $i = 0; $i < $numSitemapPages; $i++ ) { if($_ECHO) echo "Page $i<br />"; $fileContents = file_get_contents( "http://www.website.co.uk/SiteMap-S" . $i . ".aspx" ); $html->load( $fileContents ); $hrefs = $html->find( "a[style=color: Blue; text-decoration: underline;]" ); if ( isset( $hrefs[ 0 ] ) ) { foreach( $hrefs as $href ) { $url = "http://www.website.co.uk/" . $href->href; $qry = "INSERT INTO sitemap(url) VALUES( '$url' )"; mysql_query( $qry, $con ); if($_ECHO) echo "MYSQL: Added $href->href to DB<br />"; } } else if($_ECHO) echo "NO URLS FOUND ON THIS PAGE!<br />"; } echo "END: Fetching site map...<br />"; exit(0); Quote Link to comment https://forums.phpfreaks.com/topic/258306-scrape-issue-new-ones-arent-adding/ Share on other sites More sharing options...
QuickOldCar Posted March 5, 2012 Share Posted March 5, 2012 If your code used to work and you made no changes.....it's most likely the website is blocking you, or looking at how you look for content they could have easily just changed their style. Try a simple file_get_contents and see if can connect to that website or webpage, maybe they are blocking you now. You could try incorporating some error checking for empty values in your code. Quote Link to comment https://forums.phpfreaks.com/topic/258306-scrape-issue-new-ones-arent-adding/#findComment-1324162 Share on other sites More sharing options...
Help!php Posted March 5, 2012 Author Share Posted March 5, 2012 They havent blocked me yet because all the information that I have kept getting replaced but not reading the new information. Quote Link to comment https://forums.phpfreaks.com/topic/258306-scrape-issue-new-ones-arent-adding/#findComment-1324175 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.