我想進入這個串列,并獲得這個串列中的鏈接背后的某些資訊(姓名、地址、號碼、來自某個公司的郵件):
['https://allianz-entwicklung-klima.de/kompensationspartner/aera-group/'/span>。
'https://allianz-entwicklung-klima.de/kompensationspartner/atmosfair-ggmbh/'。
'https://allianz-entwicklung-klima.de/kompensationspartner/bischoff-ditze-energy-gmbh-co-kg/'。
'https://allianz-entwicklung-klima.de/kompensationspartner/climate-extender-gmbh/'。
'https://allianz-entwicklung-klima.de/kompensationspartner/climatepartner-gmbh/'。
'https://allianz-entwicklung-klima.de/kompensationspartner/die-klimamanufaktur-gmbh/'。
'https://allianz-entwicklung-klima.de/kompensationspartner/die-ofenmacher-e-v/'。
'https://allianz-entwicklung-klima.de/kompensationspartner/first-climate/'。
'https://allianz-entwicklung-klima.de/kompensationspartner/fokus-zukunft-gmbh-co-kg/']
所有的資訊最后都應該存盤在一個表中。 我嘗試了一個for回圈,但它對我不起作用,因為我只得到了第一個鏈接,而不是其他的。
我很感謝任何幫助
。uj5u.com熱心網友回復:
就我個人而言,對于任何網路搜刮,我都會使用Selenium Web Driver。這將允許你用代碼來自動化你的瀏覽器。它可以進入每個鏈接,選擇你需要的東西,存盤它們的值,并回傳它們。
uj5u.com熱心網友回復:
你可以使用一個叫做request和BeautifulSoup的Python庫來搜刮這些網站。我在下面寫了一些小代碼,我還沒有時間測驗它。但它應該可以作業。
data = [{"name": "", "address": "", "number": "", "mail": ""}]/code>
import requests
from bs4 import BeautifulSoup
links = ['https://allianz-entwicklung-klima.de/kompensationspartner/aera-group/',
'https://allianz-entwicklung-klima.de/kompensationspartner/atmosfair-ggmbh/'。
'https://allianz-entwicklung-klima.de/kompensationspartner/bischoff-ditze-energy-gmbh-co-kg/'。
'https://allianz-entwicklung-klima.de/kompensationspartner/climate-extender-gmbh/'。
'https://allianz-entwicklung-klima.de/kompensationspartner/climatepartner-gmbh/'。
'https://allianz-entwicklung-klima.de/kompensationspartner/die-klimamanufaktur-gmbh/'。
'https://allianz-entwicklung-klima.de/kompensationspartner/die-ofenmacher-e-v/'。
'https://allianz-entwicklung-klima.de/kompensationspartner/first-climate/'。
'https://allianz-entwicklung-klima.de/kompensationspartner/fokus-zukunft-gmbh-co-kg/']
for link in links:
page = requests.get(link)
soup = BeautifulSoup(page.content, "html.parser")
要學習如何提取和使用Beautiful Soup,我建議閱讀這個。Beautiful Soup。用Python構建一個網路刮刀
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/308542.html
標籤:
上一篇:Arrow-kt:如何將Either<E,List<Either<E,A>>變成Either<E,List<B>>?
下一篇:合并字典中的重復值
