即時新編程和計算機一般。我得到了一點 的基本知識,我試圖做一個易趣刮板一直在努力。在Ebay Scrape中指定列表標題
r = requests.get(url)
soup = BeautifulSoup(r.content, 'lxml')
titles = soup.find_all('a', {'class':'vip'})
titles = str(titles)
print(titles)
此代碼返回一個列表,像這樣:
[
<a class="vip" href="http://www.ebay.com/itm/HAYNES-HONDA-CIVIC-DEL-SOL-1991-1995-REPAIR-MANUAL-/121848077988?hash=item1c5eb61ea4:g:M5gAAOSwf-VWahyW&vxp=mtr" title="Click this link to access HAYNES HONDA CIVIC DEL SOL 1991-1995 REPAIR MANUAL">HAYNES HONDA CIVIC DEL SOL 1991-1995 REPAIR MANUAL</a>,
<a class="vip" href="http://www.ebay.com/itm/1992-1995-HONDA-CIVIC-DEL-SOL-FUSE-BOX-/320502127733?hash=item4a9f6a5c75:m:mHAEk2bNyOI4W8-qUiEnGWw&vxp=mtr" title="Click this link to access 1992 - 1995 HONDA CIVIC/DEL SOL FUSE BOX">1992 - 1995 HONDA CIVIC/DEL SOL FUSE BOX</a>,
<a class="vip" href="http://www.ebay.com/itm/HAYNES-HONDA-CIVIC-DEL-SOL-1991-1995-REPAIR-MANUAL-/111847121189?hash=item1a0a9ba125:g:M5gAAOSwf-VWahyW&vxp=mtr" title="Click this link to access HAYNES HONDA CIVIC DEL SOL 1991-1995 REPAIR MANUAL">HAYNES HONDA CIVIC DEL SOL 1991-1995 REPAIR MANUAL</a>,
<a class="vip" href="http://www.ebay.com/itm/1996-2000-HONDA-CIVIC-DEL-SOL-all-models-repair-manual-/401035736130?hash=item5d5f97b442:g:UjAAAOSwxN5WXm-M&vxp=mtr" title="Click this link to access 1996-2000 HONDA CIVIC & DEL SOL - all models - repair manual">1996-2000 HONDA CIVIC & DEL SOL - all models - repair manual</a>,
<a class="vip" href="http://www.ebay.com/itm/Haynes-42024-1992-1995-Honda-Civic-and-del-sol-repair-manual-/321920364888?hash=item4af3f2f158:g:9GoAAOSwLzdWRog0&vxp=mtr" title="Click this link to access Haynes 42024 1992-1995 Honda Civic and del sol repair manual.">Haynes 42024 1992-1995 Honda Civic and del sol repair manual.</a>,
<a class="vip" href="http://www.ebay.com/itm/1988-2000-honda-acura-civic-integra-del-sol-pvc-valve-17130-pm6-003-oem-a137-/141782449307?hash=item2102e47c9b:g:iB8AAOSw0HVWAg5x&vxp=mtr" title="Click this link to access 1988-2000 honda acura civic integra del sol pvc valve 17130-pm6-003 oem a137">1988-2000 honda acura civic integra del sol pvc valve 17130-pm6-003 oem a137</a>,
<a class="vip" href="http://www.ebay.com/itm/88-2000-Honda-Civic-5-Speed-Manual-Shift-Knob-OEM-CRX-EF-EG-Si-Del-Sol-89-96-/262152990857?hash=item3d09893089:g:1x4AAOSwlV9WT7fj&vxp=mtr" title="Click this link to access 88 - 2000 Honda Civic 5 Speed Manual Shift Knob OEM CRX EF EG Si Del Sol 89 96">88 - 2000 Honda Civic 5 Speed Manual Shift Knob OEM CRX EF EG Si Del Sol 89 96</a>,
<a class="vip" href="http://www.ebay.com/itm/1988-2000-Honda-Civic-CRX-EF-SI-DX-HF-Del-Sol-Manual-Shift-Knob-OEM-88-91-/281859356536?hash=item41a0207778:g:XTAAAOSwMmBVj5mr&vxp=mtr" title="Click this link to access 1988-2000 Honda Civic CRX EF SI DX HF Del Sol Manual Shift Knob OEM 88-91">1988-2000 Honda Civic CRX EF SI DX HF Del Sol Manual Shift Knob OEM 88-91</a>,
<a class="vip" href="http://www.ebay.com/itm/Chilton-Repair-Manual-Honda-Civic-Del-Sol-1996-00-/262123397570?hash=item3d07c5a1c2:g:decAAOSwA4dWNs07&vxp=mtr" title="Click this link to access Chilton Repair Manual Honda Civic & Del Sol, 1996-00">Chilton Repair Manual Honda Civic & Del Sol, 1996-00</a>
]
什麼,我想在這一點上做的,是專門接收上市JUST稱號。這樣我就可以計算出我列表中每個單詞的頻率。
預期輸出:
[
'1992 - 1995 HONDA CIVIC/DEL SOL FUSE BOX',
'Chilton Repair Manual Honda Civic & Del Sol, 1996-00',
'ETC'
]
,如果你會發現,有在每個顯示的標題行兩個地方。第一次在
"title=Click this link to access..."
並且再次緊跟其後,並且行結束。 我試過使用string.split()和其他變體,但我無法弄清楚如何以這種方式使用它,只會指定標題中的單詞。我不斷得到不同的文字,每行一個字母,或只是整個列表項等,等等。
有人知道一個好方法嗎?
我會推薦加入eBay開發者和使用他們的API。它更好,更自由。 https://go.developer.ebay.com – dstudeba