Answer the question
In order to leave comments, you need to log in
How to parse the number of downloads from Yandex Disk?
Hello! I'm trying to parse the number of downloads of a file from a Yandex disk using a link using Simple Html Dom and Xpath, but no data is returned in my xpath.
The code:
//Подключаю simple html dom
include('simple_html_dom.php');
//Исходный сайт
$content = file_get_html('https://yadi.sk/d/KFWd3TJJpdi9W');
//xpath
foreach ($content->find('//*[@id="nb-1"]/body/div[1]/div[1]/div/div[2]/div[2]/div/div[1]/div[2]/div[4]/span[2]') as $link) {
echo $link;
}
<span class="item-details__content">7 раз</span>
<div class="item-details">
<span class="item-details__name">Скачан:</span>
<span class="item-details__content">7 раз</span>
</div>
Answer the question
In order to leave comments, you need to log in
Good afternoon!
If you're using composer, you might want to use DomCrawler, which allows you to select css selectors. Which is nicer than xpath in my opinion. If you want to continue on simple_html_dom, you can put an extension on firebug - firepath, which will generate xpath for you. There is an XPath Helper for chrome that does the same thing, but I haven't tried using it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question