This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| # ... | |
| $ch = curl_init(); | |
| if($ch){ | |
| # ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <? | |
| // original curl request up here | |
| if ($headers['http_code'] == 302){ | |
| $ch = @curl_init(); | |
| curl_setopt($ch, CURLOPT_URL, $headers['redirect_url']); | |
| curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 15); | |
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
| curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookies.txt'); // set cookie file to given file |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <? | |
| # ... | |
| $content = curl_exec($ch); | |
| $headers = curl_getinfo($ch); | |
| curl_close($ch); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| # ... | |
| curl_setopt($ch, CURLOPT_URL, $url); | |
| curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 15); | |
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
| curl_setopt($ch, CURLOPT_POST, 1); | |
| curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata); | |
| curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookies.txt'); // set cookie file to given file |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| # ... | |
| $url = 'http://www.website.com/login.php'; | |
| $postdata = array('username' => "Jamie", 'password' => "password"); | |
| # ... | |
| ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $url = 'http://www.website.com/login.php'; | |
| $postdata = array('username' => "Jamie",'password' => "password"); | |
| $ch = curl_init(); | |
| if($ch){ | |
| curl_setopt($ch, CURLOPT_URL, $url); | |
| curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 15); | |
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
| curl_setopt($ch, CURLOPT_POST, 1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $dom = new DOMDocument(); | |
| @$dom->loadHTML($content); | |
| $tempDom = new DOMDocument(); | |
| $xpath = new DOMXPath($dom); | |
| $container = $xpath->query("//div[@id='container']"); | |
| foreach ( $container as $item ) { | |
| $tempDom->appendChild($tempDom->importNode($item,true)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html> | |
| <head> | |
| <title>Test</title> | |
| </head> | |
| <body> | |
| <div id="container"> | |
| <div id="person"> | |
| <p>Bob</p> | |
| <p>25</p> | |
| <p>180lbs</p> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // $content is the content you scraped (via curl for example) | |
| $dom = new DOMDocument(); | |
| @$dom->loadHTML($content) | |
| $xpath = new DOMXPath($dom); | |
| $imgSrc = $xpath->query("//html/body/div[1]/div[1]/img/@src"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html> | |
| <head> | |
| <title>Test</title> | |
| </head> | |
| <body> | |
| <div> | |
| <div> | |
| <p class="bodyText">This is left</p> | |
| <img src="images/test.jpg" /> | |
| </div> |