phpnoob34 Posted July 1, 2021 Share Posted July 1, 2021 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? Quote Link to comment https://forums.phpfreaks.com/topic/313015-i-need-help-with-curl/ Share on other sites More sharing options...
requinix Posted July 1, 2021 Share Posted July 1, 2021 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. Quote Link to comment https://forums.phpfreaks.com/topic/313015-i-need-help-with-curl/#findComment-1587704 Share on other sites More sharing options...
phpnoob34 Posted July 2, 2021 Author Share Posted July 2, 2021 ok let's say I want to get "welcome to the BBC " from https://www.bbc.co.uk . That's just a simple example. I know I can get single items using HTML DOM STRUCTURE, but for some reason its not working. I have done with tutorial. Quote Link to comment https://forums.phpfreaks.com/topic/313015-i-need-help-with-curl/#findComment-1587750 Share on other sites More sharing options...
requinix Posted July 2, 2021 Share Posted July 2, 2021 If you're having problem with your code and want help making it work then you're going to have to post the code. Quote Link to comment https://forums.phpfreaks.com/topic/313015-i-need-help-with-curl/#findComment-1587760 Share on other sites More sharing options...
phpnoob34 Posted July 5, 2021 Author Share Posted July 5, 2021 <?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. Quote Link to comment https://forums.phpfreaks.com/topic/313015-i-need-help-with-curl/#findComment-1587844 Share on other sites More sharing options...
requinix Posted July 5, 2021 Share Posted July 5, 2021 Great. Code is a good first step. The next step is describing your problem: what are you trying to do, what do you expect to see, and what are you actually seeing? Quote Link to comment https://forums.phpfreaks.com/topic/313015-i-need-help-with-curl/#findComment-1587845 Share on other sites More sharing options...
phpnoob34 Posted July 7, 2021 Author Share Posted July 7, 2021 Let me try to find it. I have this code on my hosting so I can show you this code live. Quote Link to comment https://forums.phpfreaks.com/topic/313015-i-need-help-with-curl/#findComment-1587871 Share on other sites More sharing options...
phpnoob34 Posted July 9, 2021 Author Share Posted July 9, 2021 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 Quote Link to comment https://forums.phpfreaks.com/topic/313015-i-need-help-with-curl/#findComment-1587903 Share on other sites More sharing options...
requinix Posted July 9, 2021 Share Posted July 9, 2021 Looks like that part is dynamically generated. Going to be a real pain to use DOM to find it. But why bother? The only thing there is some static text and a link with a static URL. Quote Link to comment https://forums.phpfreaks.com/topic/313015-i-need-help-with-curl/#findComment-1587904 Share on other sites More sharing options...
phpnoob34 Posted July 9, 2021 Author Share Posted July 9, 2021 well the thing is when you login you can get some stuff which is dynamically generated and I really want to get this items so I don't have to check more than 100 websites. Quote Link to comment https://forums.phpfreaks.com/topic/313015-i-need-help-with-curl/#findComment-1587919 Share on other sites More sharing options...
requinix Posted July 9, 2021 Share Posted July 9, 2021 What is an sample of the HTML you're trying to locate? Some actual HTML. Make sure you're doing a View Source of the page and not looking at the rendered version through the browser's developer tools. Quote Link to comment https://forums.phpfreaks.com/topic/313015-i-need-help-with-curl/#findComment-1587920 Share on other sites More sharing options...
phpnoob34 Posted July 15, 2021 Author Share Posted July 15, 2021 (edited) 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 July 15, 2021 by phpnoob34 Quote Link to comment https://forums.phpfreaks.com/topic/313015-i-need-help-with-curl/#findComment-1588354 Share on other sites More sharing options...
requinix Posted July 15, 2021 Share Posted July 15, 2021 You might be able to search for a div with a class that starts "css-" and ends "-metrics" (check that). I think I would then "render" the whole thing to text and run a regular expression to parse it. Quote Link to comment https://forums.phpfreaks.com/topic/313015-i-need-help-with-curl/#findComment-1588355 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.