Jump to content

Recommended Posts

Hey guys 

I need help with curl php . I cannot get info from other website. I have been trying to get single post but I'm gettig the whole page or more than one post. I get tutorial from youtube, but for some reason its not working.  Does anyone can help me with simple example ? code prehaps?

Link to comment
https://forums.phpfreaks.com/topic/313015-i-need-help-with-curl/
Share on other sites

2 hours ago, phpnoob34 said:

I have been trying to get single post but I'm gettig the whole page or more than one post.

cURL can't extract a part of a webpage for you. You get the whole thing.

How about a better and more detailed explanation of what you're trying to do, what website and "posts" you're talking about, and what's going wrong? Make sure to post your code too.

<?php
include "simple_html_dom.php";
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://ahrefs.com/site-explorer/overview/v2/subdomains/live?target=karramba.se');
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER,1 );
$response = curl_exec($curl);
curl_close($curl);


echo $response; 

$html = new simple_html_dom();
$html->load($response);
foreach($html->find('div[CollapsingNavbarHeader]') as $link)
echo $link->plaintext;
?>
 

I was trying to get some info from Ahrefs. can you help me to display single post or image from Ahrefs , so you will give me as an example. 

http://karramba.se/test/curl.php thats the link to the website. I'm seeing the whole main page of ahrefs but I want to get  the part in the middle of the page 

 

"

Try Ahrefs now

Start using Ahrefs Site Explorer tool and dive into all this powerful data right now!Start trial

 

for example

I'd like to get this data from this code

 

 

<div class="css-16oi4kv-metrics"><div class="css-a5m6co-text css-p8ym46-fontFamily css-1s1cif8-fontSize css-mun6jo-color css-15qzf5r-display">Crawled</div><div class="css-a5m6co-text css-p8ym46-fontFamily css-1s1cif8-fontSize css-mun6jo-color css-wmls8-align css-15qzf5r-display">49.3K</div><div class="css-3sdovo-deltaCell"><div class="css-a5m6co-text css-p8ym46-fontFamily css-1s1cif8-fontSize css-1u51kiy-color css-15qzf5r-display">−522</div></div><div class="css-a5m6co-text css-p8ym46-fontFamily css-1s1cif8-fontSize css-mun6jo-color css-15qzf5r-display">Redirects</div><div class="css-a5m6co-text css-p8ym46-fontFamily css-1s1cif8-fontSize css-mun6jo-color css-wmls8-align css-15qzf5r-display">201</div><div class="css-3sdovo-deltaCell"><div class="css-a5m6co-text css-p8ym46-fontFamily css-1s1cif8-fontSize css-12oi5yl-color css-15qzf5r-display">−2</div></div><div class="css-a5m6co-text css-p8ym46-fontFamily css-1s1cif8-fontSize css-mun6jo-color css-15qzf5r-display">Broken</div><div class="css-a5m6co-text css-p8ym46-fontFamily css-1s1cif8-fontSize css-mun6jo-color css-wmls8-align css-15qzf5r-display">325</div><div class="css-3sdovo-deltaCell"><div class="css-a5m6co-text css-p8ym46-fontFamily css-1s1cif8-fontSize css-1u51kiy-color css-15qzf5r-display">+306</div></div><div class="css-a5m6co-text css-p8ym46-fontFamily css-1s1cif8-fontSize css-mun6jo-color css-15qzf5r-display">Blocked</div><div class="css-a5m6co-text css-p8ym46-fontFamily css-1s1cif8-fontSize css-mun6jo-color css-wmls8-align css-15qzf5r-display">5</div><div class="css-3sdovo-deltaCell"></div></div>

Edited by phpnoob34
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.