[英]how to scrape multiple pages with static url, request method get
首先,對不起我的英語,其次,我在 python 中只有 2 周大。
現在我使用 python,模塊 selenium 和 chromedriver,我要抓取的頁面是“http://lpse.maroskab.go.id/eproc”,
from time import sleep
from selenium import webdriver
from bs4 import BeautifulSoup as bs
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument("disable-extensions")
chrome_options.add_argument("disable-gpu")
chrome_options.add_argument("headless")
path =r'F:\python latian\webdriver\chromedriver.exe'
driver = webdriver.Chrome(options=chrome_options, executable_path = path)
driver.get('http://lpse.maroskab.go.id/eproc4/lelang')
sleep(5)
page=bs(driver.page_source,"html.parser")
code=page.find_all(class_="sorting_1")
for xx in code:
kode=xx.contents[0]
print(code)
但是使用這段代碼我只從第一頁獲取數據,而我想要完成的是抓取另一頁,然后我遇到了([this thread][1]),但該線程中的答案請求方法是“ post" ,在我的是"get" 。 我在那里讀到了使用“urllib.request”的建議,但我知道這種方法只有在我知道 url 時才有效。 謝謝[1]:https://stackoverflow.com/questions/48985758/how-to-scrape-multiple-pages-with-an-unchanging-url-python-3
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.