# - * - coding: utf8 - * -
The import requests
The from bs4 import BeautifulSoup
Headers={' the user-agent ':' Mozilla/5.0 (Windows NT 10.0; Win64. X64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36 '}
Def RequestWithPageno (pageno=1) :
Form_data={
https://bbs.csdn.net/topics/'sortorder: 0,
'pagesize: 24,
'pageno: pageno}
# url="https://www.turners.co.nz/Cars/Used-Cars-for-Sale/? Sortorder=0 & amp; Pagesize=24 & amp;='+ pageno STR (pageno)
The response=requests. Get (url, headers=headers, data=https://bbs.csdn.net/topics/form_data)
Soup=BeautifulSoup (the response text, '. The HTML parser)
Divs=soup. Select (' # searchResultsContainer & gt; Div ')
For div divs in:
# according to the first vehicle information
Goodnumber=div. Get (" data - goodnumber ")
Print (goodnumber)
Break
# url="https://www.turners.co.nz/Cars/Used-Cars-for-Sale/? Sortorder=0 & amp; Pagesize=24 & amp; Pageno=1 '
Url='https://www.turners.co.nz/Cars/Used-Cars-for-Sale'
If __name__=="__main__" :
Pageno=1
While True:
Print (pageno)
RequestWithPageno (pageno=pageno)
Pageno +=1
Found in the process of problem solving of the following:
The browser operation, the first page of the site is https://www.turners.co.nz/Cars/Used-Cars-for-Sale/? Sortorder=0 & amp; Pagesize=24 & amp; Pageno=1, click on the page page tags to jump, after the page url is https://www.turners.co.nz/Cars/Used-Cars-for-Sale/? Sortorder=0 & amp; Pagesize=24 & amp; Pageno=2;
If direct input https://www.turners.co.nz/Cars/Used-Cars-for-Sale/? in your browser Sortorder=0 & amp; Pagesize=24 & amp; Pageno=2, will automatically jump to the first page,
For bosses to give directions!!!!!!
CodePudding user response:
Don't use python + selenium how should solve???????