简体   繁体   English

javascript生成的python goto链接

[英]python goto link generated by javascript

everybody! 大家! i need to get some data from website, that generate its content with javascript. 我需要从网站获取一些数据,这些数据会用javascript生成。 somehow, with ClientForm module help, i could authorize on the site and get needed data by passing needed form values to search lists. 以某种方式,在ClientForm模块帮助下,我可以在站点上进行授权并通过将所需的表单值传递给搜索列表来获取所需的数据。 but than, i get a few pages of results. 但是比起,我得到了几页结果。 and i need to loop over that pages, saving them. 我需要遍历该页面,保存它们。 but the point is that 'NEXT' page button looked like 但关键是“ NEXT”页面按钮看起来像

a onclick="if(typeof jsfcljs == 'function') { 
               jsfcljs(document.getElementById('nestedView:j_id_id8pc10'),           
                   {'nestedView:j_id_id8pc10:next':'nestedView:j_id_id8pc10:next'},
                   '');
           }
           return false"
href="#" id="nestedView:j_id_id8pc10:next">next

how could i move on this link with python? 我该如何使用python进行此链接?

Your options are essentially: 您的选择基本上是:

  1. Work out what the javascript is doing, and try to copy it in Python, so that the server sends you the same data. 找出javascript的功能,然后尝试用Python复制它,以便服务器向您发送相同的数据。 If you're not already using it, Firebug is the sort of thing you'll need. 如果您尚未使用Firebug,那您将需要它。
  2. Use a browser control framework, such as Selenium RC, to interact with a browser using Python. 使用浏览器控制框架,例如Selenium RC,可以使用Python与浏览器进行交互。

Generally, option 1 is more straightforward unless you're already familiar with using a framework to control a browser, or the javascript is really, horribly hard to follow. 通常,除非您已经熟悉使用框架来控制浏览器,或者javascript确实很难遵循,否则选项1更直接。

Oh, and 3: Write a javascript+DOM engine in Python. 哦,还有3:用Python编写一个javascript + DOM引擎。 (No, that's a joke. There's a reason one doesn't already exist.) (不,这是个玩笑。这是一个不存在的原因。)

maybe i can simulate a POST request (capture it from Live HTTP Headers in firefox, for example) and navigate on site such way? 也许我可以模拟POST请求(例如,从firefox中的Live HTTP Headers捕获它)并以这种方式在网站上导航? cause the main point is to get data...and steps to get it are similar (log in, fill 2 search forms, loop through results pages) 因为主要要点是获取数据...并且获取数据的步骤是相似的(登录,填写2个搜索表单,遍历结果页面)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM