[英]Scrape data from website with frames or flexbox using python requests and BeautifulSoup
I've been trying to figure this out but with no luck.我一直试图弄清楚这一点,但没有运气。 I found a thread ( How to scrape data from flexbox element/container with Python and Beautiful Soup ) that I thought would help but I can't seem to make any headway.我发现了一个线程( How to scrape data from flexbox element/container with Python and Beautiful Soup )我认为这会有所帮助,但我似乎无法取得任何进展。
The site I'm trying to scrape is...http://www.northwest.williams.com/NWP_Portal/.我要抓取的网站是...http://www.northwest.williams.com/NWP_Portal/。 In particular I want to get the data from the tab/frame of 'Storage Levels' but for the life of me I can't seem to navigate to the right spot to get the data.特别是我想从“存储级别”的选项卡/框架中获取数据,但对于我来说,我似乎无法导航到正确的位置来获取数据。 I've tried various iterations of the code below with no success.我已经尝试了下面代码的各种迭代,但没有成功。 I've changed 'lxml' to 'html.parser', looked for tables, looked for 'tr' etc but the code always returns empty.我已将“lxml”更改为“html.parser”,查找表,查找“tr”等,但代码始终返回空。 I've also tried looking at the network info but when I click on any of the tabs (System Status, PAL/System Balancing etc) I don't see any change in network activity.我也试过查看网络信息,但是当我点击任何选项卡(系统状态、PAL/系统平衡等)时,我看不到网络活动有任何变化。 I'm sure it's something simple that I'm overlooking but I just can't put my finger on it.我敢肯定,我忽略了一些简单的事情,但我就是不能把手指放在上面。
from bs4 import BeautifulSoup as soup
import requests
url = 'http://www.northwest.williams.com/NWP_Portal/'
r = requests.get(url)
html = soup(r.content,'lxml')
page = html.findAll('div',{'class':'dailyOperations-panels'})
How can I 'navigate' to the 'Storage Levels' frame/tab?如何“导航”到“存储级别”框架/选项卡? What is the html that I'm actually looking for?我真正在寻找的 html 是什么? Can I do this with just requests and beautiful soup?我可以只用请求和漂亮的汤来做到这一点吗? I'm not opposed to using Selenium but I haven't used it before and would prefer to just use requests and BeautifulSoup if possible.我不反对使用 Selenium 但我以前没有使用过它,如果可能的话,我宁愿只使用请求和 BeautifulSoup。
Thanks in advance!提前致谢!
Hey so what I notice is your are trying to get "dailyOperations-panels" from a div which won't work.嘿,所以我注意到你正试图从一个不起作用的 div 中获取“dailyOperations-panels”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.