使用 python 访问和网络抓取动态页面

Access and webscrape dynamic pages using python

我正在尝试使用其表单参数访问网页。 我在 chrome 的开发人员选项卡中使用 Network headers 找到了表单参数。 但它不起作用,它只是在使用这些参数之前打开页面(即 www.irishancestors.ie/search/townlands/ded_index.php

import webbrowser

webbrowser.open('http://www.irishancestors.ie/search/townlands/ded_index.php?action=listp&parish=Aghagallon')

我的目的是检索所有县的每个选区的所有表。

webbrowser 并不像您想象的那样。

如果你想get/post数据到网页,你应该使用requests

>>> import requests
>>> r = requests.get('https://api.github.com/events')
>>> r = requests.post('http://httpbin.org/post', data = {'key':'value'})

webbrowser 用于启动您的网络浏览器。

请注意,如果有一堆 javascript 在使用,这将不会很好地工作(好吧,它可能,但它需要你做更多的工作)。如果你有很多Javascript,用selenium

可能更容易