Jump to content

file_Get_content


Help!php

Recommended Posts

I am trying to get content from a website but it doesnt seem to be working. It creates a table and the columns needed but after that the code is not reading.

 

<div style="padding-top: 10px; float: left; clear: both;">

<a style="color: Blue; text-decoration: underline;" href="index.aspx"> Index </a>

</div>

 

This is the part thats on the site and I just want to get the href bit "index.aspx".

 

for( $i = 0; $i < $numSitemapPages; $i++ )
{
	if($_ECHO) echo "Page $i<br />";

	$fileContents = file_get_contents( "http://www.website.co.uk/SiteMap" . $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 SITEMAPP (url) VALUES( '$url' )";
			//echo $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 />";
}

 

This is the for loop statement which should work. But not working. any idea why???

Link to comment
https://forums.phpfreaks.com/topic/259736-file_get_content/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.