I am trying to scrape some data from a webpage using bs4
Given below is what I have done thus far,
(我正在尝试使用bs4
从网页上抓取一些数据鉴于以下是我到目前为止所做的事情,)
import requests
from bs4 import BeautifulSoup
url = 'www.website.com'
response = requests.get(url)
soup = BeautifulSoup(response.text, "html.parser")
for article in soup.find_all('section'):
print(article)
The above code returns the below output:
(上面的代码返回以下输出:)
<section>
<ul class="row-full-width" style="margin:0; list-style: none; padding-left: 0; font-size: 120%">
<li class="four columns">
Comp A:
<i class="icon-rupee"></i>
<b>136.90</b>
Cr.
</li>
<li class="four columns">
Comp B:
<i class="icon-rupee"></i>
<b>10.95</b>
</li>
<li class="four columns">
Comp C:
<i class="icon-rupee"></i> <b>49.60</b> / <b>10.20</b>
</li>
<li class="four columns">
Comp D:
<i class="icon-rupee"></i>
<b>6.61</b>
</li>
<li class="four columns">
Comp E:
<b>25.78</b>
</li>
<li class="four columns">
Comp F:
<b>0.00</b>
%
</li>
<li class="four columns">
Comp G:
<b>9.39</b>
%
</li>
<li class="four columns">
Comp H:
<b>6.54</b>
%
</li>
<li class="four columns">
Comp I:
<b>19.39</b>
%
</li>
<li class="four columns">
I am trying to extract each of the Comp's and their corresponding values:
(我试图提取每个Comp及其对应的值:)
Expected Output :
(预期产量:)
Comp A,136.90 Cr
Comp B, 10.95
Comp C, 49.60/10.20
Comp D, 6.61
Comp E, 25.78
Comp F, 0.0%
Comp G, 9.39%
Comp H, 6.54%
Comp I, 19.39%
ask by scott martin translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…