https://shipandbunker.com/prices/emea/nwe/nl-rtm-rotterdam#_IFO380
我想从上面的网站上的动态图表中获取2019年4月7日鹿特丹-IFO380的价格($380.50)
如果我想将数据存储到本地数据库中,我不确定beautifulsoup是否是最好的方法
from bs4 import BeautifulSoup
import requests
import pymongo
# URL of page to be scraped
url = 'https://shipandbunker.com/prices/emea/nwe/nl-rtm-rotterdam#IFO380'
# Retrieve page with the requests module
response = requests.get(url)
# Create BeautifulSoup object; parse with 'lxml'
soup = BeautifulSoup(response.text, 'lxml')
下面是一种在json中搜索特定日期的方法,json是从您可以在网络选项卡中找到的API调用动态返回的。实现与另一个答案略有不同
此页面使用JavaScript获取所有数据并创建图形
JavaScript使用
POST
请求和url https://shipandbunker.com/a/.json来获取JSON格式的数据,该格式可以轻松转换为Python字典,并且不需要BeautifulSoup来刮取HTML它显示
您可以使用
Scrapy
刮取您想要的每个站点下面是一个简单的爬行器:
spider.py
设置和管理spider非常容易,下面是Doc
相关问题 更多 >
编程相关推荐