2

On the following page: http://v.qq.com/cover/y/yemixtioybrdw5x.html?vid=l00139h6ft5, I am trying to scrape the number of views (375.5 万). This seems to be generated dynamically, probably getting data from a json somewhere.

As I try to find that json, how can I know which javascript function changed the value of this element?

<em class="num" id="act_playnum">375.5 万</em>

Apologies for my lack of web development knowledge

Spencer Wieczorek
  • 21,229
  • 7
  • 44
  • 54
Alexis Eggermont
  • 7,665
  • 24
  • 60
  • 93
  • 1
    That page is taking a long time to load on my machine, anyways if you look at the source code you would want to look for a reference to the id `act_playnum`. Such as `document.getElementById("act_playnum")` or `$("act_playnum")`. – Spencer Wieczorek Dec 17 '15 at 03:57
  • @AnikIslamAbhi The blockquote is for direct quotes from sources, not for links. – Spencer Wieczorek Dec 17 '15 at 03:59
  • 1
    Though this isn't exactly an answer to your question, you may want to go about this in a different way. Instead of finding the script that modifies this element, use the [Chrome Dev Tools](https://developer.chrome.com/devtools) to look for all outgoing requests. You can sort their doctypes by *.json, and then inspect each for your variable of interest. – j6m8 Dec 17 '15 at 03:59
  • That's the one thing I tried, and the id is not mentioned anywhere in the source code (neither is the class). – Alexis Eggermont Dec 17 '15 at 04:01
  • To expand on my earlier comment, you could also use Chrome Dev Tools to search for the '万' character in source-code, as it's likely that it's being generated dynamically (not all videos will have that many views, for instance.) – j6m8 Dec 17 '15 at 04:05
  • @j6m8 Thanks. I was able to find the GET request that returns this json using what you suggested. However I'm not able to understand how this GET request was generated (one of its variables is the video ID, but I cannot find this video ID in the source code or url of the video page). Is there a way to know what generated a GET request? – Alexis Eggermont Dec 17 '15 at 05:27
  • Possible duplicate of [How to find out the piece of code that initiated ajax request](http://stackoverflow.com/questions/10389846/how-to-find-out-the-piece-of-code-that-initiated-ajax-request) – Sheepy Dec 17 '15 at 05:51

0 Answers0