如何使用 Mechanize 抓取 HP 打印机状态页?
状态页面如下所示:
http://h20000.www2.hp.com/bc/docs/support/SupportDocument/c00002742/c00004781.gif
您看到设备状态标题下方的文本了吗?这就是我想要刮的。
导航至时,状态页面会更新。我从页面源代码中提取了此内容:
<form id="deviceStatusPage" method="post" action="this.LCDispatcher?nav=hp.DeviceStatus">
我似乎无法理解它实际上在做什么,因此很难制定出良好的抓取策略。我相当确定解决方案将是微不足道的,但我似乎根本无法开始。
应该说我一直在玩机械化和美丽汤。前者似乎可以实现我想要的目标,但我不确定如何实现。
The status page looks like this:
http://h20000.www2.hp.com/bc/docs/support/SupportDocument/c00002742/c00004781.gif
You see the text underneath the Device Status title? That's what I want to scrape.
When navigated to, the status page is updated. I've pulled this from the page source:
<form id="deviceStatusPage" method="post" action="this.LCDispatcher?nav=hp.DeviceStatus">
I can't seem to understand what it's actually DOING so it's hard to work out a good scraping strategy. I'm fairly sure the solution will be trivial but I can't seem to get started at all.
Should have said I've been playing with Mechanize and Beautiful Soup. The former seems like it'd achieve what I'd want, but I'm not sure how.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用抓取库。
BeautifulSoup
是一个很棒的。mechanize
和BeautifulSoup
一起构成了非常有用的抓取工具。Use a scraping library.
BeautifulSoup
is a great one.mechanize
andBeautifulSoup
together makes very useful scrapers.