Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用BeautifulSoup和Python刮取多个表页_Python_Html_Web Scraping_Page Numbering - Fatal编程技术网

使用BeautifulSoup和Python刮取多个表页

使用BeautifulSoup和Python刮取多个表页,python,html,web-scraping,page-numbering,Python,Html,Web Scraping,Page Numbering,我想用python BS4删除此url上可用的表,但当我更改表大小或更改页面时,url不会更改。在表中导航时,url不会更改,因为表似乎是使用javascript(特别是DataTables库)实现的,并使用AJAX获取要显示的相关数据 因此,基本上,我看不出有什么方法可以在页面加载时使用BS4刮取页面并获取默认显示以外的数据 另一方面,当使用AJAX检索数据时,您可以尝试找出AJAX请求的格式(什么参数对您想要的结果做什么,例如使用Firebug),并通过调用提供数据表的AJAX URL直接以


我想用python BS4删除此url上可用的表,但当我更改表大小或更改页面时,url不会更改。

在表中导航时,url不会更改,因为表似乎是使用javascript(特别是DataTables库)实现的,并使用AJAX获取要显示的相关数据

因此,基本上,我看不出有什么方法可以在页面加载时使用BS4刮取页面并获取默认显示以外的数据

另一方面,当使用AJAX检索数据时,您可以尝试找出AJAX请求的格式(什么参数对您想要的结果做什么,例如使用Firebug),并通过调用提供数据表的AJAX URL直接以JSON格式检索数据


但是,根据你打算使用的数据,你可能会考虑向网站所有者请求下载和使用数据。而且,谁知道呢?他们可能愿意提供帮助。

这是一个通过GET发送到服务器的ajax调用,下面是python中快速而肮脏的废弃代码

ajax url是


它每次都给我相同的页面。不,我实际上并没有尝试过,我尝试过用不同的时间段测试url,结果都是一样的。
import requests,time
c=0
data=list()
for i in range(1,2278):
    url='http://results.xacte.com/json/search?eventId=1387&callback=jQuery18309972286304579958_1494520029659&sEcho=8&iColumns=13&sColumns=&iDisplayStart='+str(c)+'&iDisplayLength=10&mDataProp_0=&mDataProp_1=bib&mDataProp_2=firstname&mDataProp_3=lastname&mDataProp_4=sex&mDataProp_5=age&mDataProp_6=city&mDataProp_7=state&mDataProp_8=country&mDataProp_9=&mDataProp_10=&mDataProp_11=&mDataProp_12=&sSearch=&bRegex=false&sSearch_0=&bRegex_0=false&bSearchable_0=false&sSearch_1=&bRegex_1=false&bSearchable_1=true&sSearch_2=&bRegex_2=false&bSearchable_2=true&sSearch_3=&bRegex_3=false&bSearchable_3=true&sSearch_4=&bRegex_4=false&bSearchable_4=true&sSearch_5=&bRegex_5=false&bSearchable_5=true&sSearch_6=&bRegex_6=false&bSearchable_6=true&sSearch_7=&bRegex_7=false&bSearchable_7=true&sSearch_8=&bRegex_8=false&bSearchable_8=true&sSearch_9=&bRegex_9=false&bSearchable_9=true&sSearch_10=&bRegex_10=false&bSearchable_10=true&sSearch_11=&bRegex_11=false&bSearchable_11=false&sSearch_12=&bRegex_12=false&bSearchable_12=false&iSortCol_0=0&sSortDir_0=asc&iSortingCols=1&bSortable_0=false&bSortable_1=true&bSortable_2=true&bSortable_3=true&bSortable_4=true&bSortable_5=true&bSortable_6=true&bSortable_7=true&bSortable_8=true&bSortable_9=false&bSortable_10=false&bSortable_11=false&bSortable_12=false&_='+str(time.time())
    r=requests.get(url)
    c+=1
    print (r.text,'-------------',)
    #do whatever you want to do with it, r.text will give the raw data.