PHP scraper help

Discussion in 'PHP' started by wpfan, Feb 11, 2011.

  1. #1
    Im teaching myself scraping with php using curl and im at a standstill trying to figure how to make the script click a JavaScript activated link.

    For example looking here http://www.tvduck.com/How-I-Met-Your-Mother.html

    How do i tell the script to click
    <a name="S1E1" rel="nofollow" href="#" onclick="javascript:updateElement('62224',''); return false;">Season 1, Episode 1: Pilot</a>

    so that it shows the underlying links?
     
    wpfan, Feb 11, 2011 IP
  2. AsHinE

    AsHinE Well-Known Member

    Messages:
    240
    Likes Received:
    8
    Best Answers:
    1
    Trophy Points:
    138
    #2
    Generally you can't tell php script to click that link using curl. But you can examine that javascript by hand and see what it does and then emulate it in php
     
    AsHinE, Feb 11, 2011 IP
  3. krdzal

    krdzal Peon

    Messages:
    105
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I think you have some bad approach there :)
     
    krdzal, Feb 11, 2011 IP
  4. mastermunj

    mastermunj Well-Known Member

    Messages:
    687
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    110
    #4
    You should check definition of javascript function updateElement.

    Mainly, it makes an ajax call to http://www.tvduck.com/thescript.php?rnd=' + Math.random()*4 + '&el_id=' + el_id + '&action=action

    where
    Math.random() is for making a url unique for avoiding cache.
    el_id is the id of the element passed into function.
    action is a static parameter valued 'action'

    Hope above helps.
     
    mastermunj, Feb 12, 2011 IP