Jump to content

PHP reading a link...


SamDOD

Recommended Posts

Is there a way to use PHP to read a specific link and extract certain information from it. For example...

To have the script read a website and to look for <table Id="somthing"> and get the <a tag and take the link and information under it? Does this make sense... is it possible... pls help! Thank you for your help

 

Link to comment
https://forums.phpfreaks.com/topic/42380-php-reading-a-link/
Share on other sites

You got three options (that I know of) to get the data:

- Using the regular file functions (best way imo if you simply need to read the file). You need allow_url_fopen enabled for that.

- Using cURL (best way imo if you need to send post data and/or use session/cookies etc). You need the curl library installed for that.

- Using sockets (never used it)

 

Then, after you get the data, you could use regular expression (preg_match() or ereg()) to get the data you want.

 

 

Hope it helps :)

Orio.

Link to comment
https://forums.phpfreaks.com/topic/42380-php-reading-a-link/#findComment-205565
Share on other sites

Here comes no.4 option. Thanks to fcicqbbs comment

 

http://my2.php.net/manual/en/function.file-get-contents.php

 

fcicqbbs at gmail dot com

04-Aug-2006 04:55

the bug #36857 was fixed.

http://bugs.php.net/36857

 

Now you may use this code,to fetch the partial content like this:

<?php
$context=array('http' => array ('header'=> 'Range: bytes=1024-', ),);
$xcontext = stream_context_create($context);
$str=file_get_contents("http://www.fcicq.net/wp/",FALSE,$xcontext);
?>

that's all.

Link to comment
https://forums.phpfreaks.com/topic/42380-php-reading-a-link/#findComment-205586
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.