Jump to content

Search the Community

Showing results for tags 'php dom'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 1 result

  1. Hi, I was reviewing a php web scraping write up which is found at http://imbuzu.wordpress.com/tag/web-scraping and discovered there is a syntax error in the author's code: THE ERROR IS ON THIS LINE (FULL SET OF CODE CAN BE FOUND AT AUTHOR'S SITE - link above) for ($i = 0; $i getElementsByTagName('td'); (I'm posting below): Note - i can't understand the logic of the 'for' loop, getElementsByTagName function to fix the problem so asking for help to make this work as the author suggested. <?php error_reporting(E_ERROR); $url = "http://www.imdb.com/chart/"; $curl = curl_init($url); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); $document = curl_exec($curl); //echo $document; $dom_rep = new DOMDocument; $dom_rep->loadHTML($document); $all_trs = $dom_rep->getElementsByTagName('tr'); $trs_we_want = array(); foreach ($all_trs as $tr) { $class_name = $tr->getAttribute('class'); if (preg_match("/chart_(even|odd)_row/", $class_name)) { $trs_we_want[] = $tr; } } for ($i = 0; $i getElementsByTagName('td'); $the_tds_arr = array(); foreach ($the_tds as $td) { $the_tds_arr[] = $td; } $movie_title = $the_tds_arr[2]->nodeValue; $rank = $the_tds_arr[0]->nodeValue; $weekend = $the_tds_arr[3]->nodeValue; $gross = $the_tds_arr[4]->nodeValue; $weeks = $the_tds_arr[5]->nodeValue; echo "<div>"; echo "<h2>$movie_title</h2>"; echo "Rank: $rank<br />"; echo "Weekend: $weekend<br />"; echo "Gross: $gross<br />"; echo "Weeks: $weeks<br />"; echo "</div>"; } ?>
×
×
  • 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.