Jump to content

Recommended Posts

hey guys . I've only been doing PHP for a month or so.. so don't go hard on me :]

 

I need to make a function, that goes to a specific website, then read the websites source code. In the source code I want it to find this line:

 

<input type="hidden" value="904af2bb79a87e81275e246c1189f887" name="abaafaasdfsasdauddgy" >

 

on line 277. Then it gets the information in "value" , and define it as $key1.

Same with "name", I just want that one as $key2.

 

Can anyone point me in the right direction? :)

Link to comment
https://forums.phpfreaks.com/topic/138375-reading-from-source-code-using-curl/
Share on other sites

Without seeing the code may not work.. but it should..

 

<?php
$HTML = file_get_contents("http://thesite.com"); // OR $file[276]; from premiso code
if (preg_match('/<input type="hidden" value="([^"]*)" name="([^"]*)" >/sim', $HTML, $regs))
{
$key1= $regs[1];
$key2= $regs[2];
}

echo "Key1=$key1<br>Key2=$key2";
?>

If you want to use cURL, you can store the source (in $contents) with the following code:

 

<?php
$url = 'page url';
$c = curl_init();
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
curl_setopt($c, CURLOPT_URL, $url);
$contents = curl_exec($c);
curl_close($c);
?>

Without seeing the code may not work.. but it should..

 

<?php
$HTML = file_get_contents("http://thesite.com"); // OR $file[276]; from premiso code
if (preg_match('/<input type="hidden" value="([^"]*)" name="([^"]*)" >/sim', $HTML, $regs))
{
$key1= $regs[1];
$key2= $regs[2];
}

echo "Key1=$key1<br>Key2=$key2";
?>

 

thanks a lot, worked for me!  ;D

 

thanks to the other contributors too :)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.