【发布时间】:2021-03-06 18:57:58
【问题描述】:
我正在尝试抓取 kurs 交易表https://www.bi.go.id/id/moneter/informasi-kurs/transaksi-bi/Default.aspx
从 2015 年到 2020 年,但问题是默认日期和我选择的日期之间的链接仍然相同。那么我如何告诉 python 从 2015-2020(20-Nov-15 -- 20-nov-20)抓取数据?我对 python 很陌生,正在使用 python 3。提前谢谢你
import requests
from bs4 import BeautifulSoup
import pandas as pd
headers={
"User-Agent":"Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.101 Safari/537.36",
"X-Requested-With":"XMLHttpRequest"
}
url = "https://www.bi.go.id/id/moneter/informasi-kurs/transaksi-bi/Default.aspx"
import requests
from lxml import html
response = requests.get(url)
content= response.content
print(content)
【问题讨论】:
-
the link between the default date and the date that I chose is still the same- adinda 的意思是 url 不会改变以反映查询的日期范围,这意味着bs4不能用于直接访问所需的页面。
标签: python web-scraping beautifulsoup screen-scraping