简体   繁体   English

自动执行网络任务?

[英]Automating web tasks?

I play on chess.com and I'd like to download a history of my games. 我在Chess.com上玩游戏,我想下载我的游戏历史。 Unfortunately, they don't make it easy: I can access 100 pages of 50 games one at a time, click "Select All" and "Download" and then they e-mail it to me. 不幸的是,他们做起来并不容易:我一次可以访问100个页面,共50个游戏,单击“全选”和“下载”,然后他们通过电子邮件将其发送给我。

Is there a way to write a script, in python or another language, that helps me automate any part of the process? 有没有一种方法可以用python或其他语言编写脚本,以帮助我使过程的任何部分自动化? Something that simulates clicking a link? 模仿点击链接的东西吗? Is Capybara useful for things like this outside of unit testing? Capybara在单元测试之外对这样的事情有用吗? Selenium? 硒?

I don't have much experience with web development yet. 我还没有Web开发方面的丰富经验。 Thanks for your help! 谢谢你的帮助!

You may want to check out CasperJS. 您可能要签出CasperJS。 I use Python to fire CasperJS scripts to do web scraping and return data to Python to parse further or store to a database etc... 我使用Python触发CasperJS脚本进行网页抓取并将数据返回给Python以进一步解析或存储到数据库等...

Python itself has BeautifulSoup and Mechanize but the combination is not great with Ajax based sites. Python本身具有BeautifulSoup和Mechanize,但对于基于Ajax的站点,这种组合并不是很好。

Python and CasperJS is perfect. Python和CasperJS很完美。

Selenium could be a good candidate if you want to do something like this. 如果您想做这样的事情,硒可能是一个不错的选择。

Here would be some pseudo code: 这是一些伪代码:

foreach page_link in page_links:
  page_link.click()
  select_all.click()
  download_link.click()

Take a look at Helium . 看看氦气 It should be relatively easy to achieve what you need to do using this Python library: 使用此Python库实现所需的工作应该相对容易一些:

start_chrome("chess.com")
...
click("Select All")
click("Download")
...

etc. 等等

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

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