Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with parsing a page element 1

Status
Not open for further replies.

s0crates9

Technical User
Jun 18, 2005
70
US
I am trying to get link popularity from google and haven't been able to isolate the section I need. Perhaps my regex is wrong or something else, but I've been experimenting with eveything and cannot seem to grab the line with results. take a look:
Code:
function getlp($url) {
    $file = "[URL unfurl="true"]http://www.google.com/search?hl=en&lr=&ie=UTF-8&q=link%3A$url";[/URL]
    $data = file($file);
    $trans="";
    preg_match_all("/[of]\s[about]\s[0-9\,]*\s[linking]\s[to]/Ui", $data[34], $regs);
    $trans=get_html_translation_table(HTML_ENTITIES);
    $result=strtr($regs[0][0], $trans);
    return $result;
}

Thanks for any help regarding this.

Web site design, internet marketing, SEO and business solutions company.
 
First I must say I am a complete novice at regular expressions (you may want to wait for some other responses), but with some testing I found this pattern to work with you code:
Code:
/of\sabout\s<b>[0-9,]+<\/b>\slinking\sto/Ui
When run your function returns: "of about <b>3,050,000</b> linking to"
Obviously the number is arbitrary...

One thing, when writing the pattern the html code is contained in the string $data[34], so the pattern must account for <b>...</b>.

HTH,
Itshim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top