php - Simple crawl to website

888

I am trying to crawl a website . Will the below code is that efficient to get me the values which I listed

<?php

include 'simple_html_dom.php';

$target_url = "http://www.phunwa.com/phone/0191/2604233";
$html = new simple_html_dom();
$html->load_file($target_url);
foreach($html->find('Name') as $link){
echo $link."<br />";
}

?>

Actaully I am trying to ftech Name , Address and location . COuld anybody please give me any idea on this.

Thanks in advance

43

Answer

Solution:

By looking at the source code, try getting the contents of thediv with classaddress-tags then looping through the

tags and echoing the contents.

Try this to start with;

$dom = new DomDocument();
$dom->loadHtml($html);
$xpath = new DomXpath($dom);
$div = $xpath->query('//*[@class="address-tags"]')->item(0);

People are also looking for solutions to the problem: php - How to change the url in codelginter

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.