我实际上制作了一个脚本,该脚本检查拍卖门户网站是否为我带来了新的感兴趣的拍卖。现在,脚本选择项目名称,类别,添加时间并创建拍卖清单。这是我的问题。我的代码:
#List of auctions
time.sleep(2)
lists= driver.find_elements_by_class_name("vela__item__1FnoI")
print ("Found " + str(len(lists)) + " auctions")
for link in driver.find_elements_by_xpath('//div[@class="vela__item__1FnoI"]//a'):
print (link.get_attribute('href') + "-" + link.text)
现在看起来很恐怖:
<selenium.webdriver.firefox.webelement.FirefoxWebElement (session="dae57d0d-9570-4693-bb7f-8aa31ab24699", element="49e4afcd-f6c3-4b62-bba0-a3b21e08c78d")>
<selenium.webdriver.firefox.webelement.FirefoxWebElement (session="dae57d0d-9570-4693-bb7f-8aa31ab24699", element="3f2a9f43-26b8-40f6-a4b6-497d46e41598")> etc
请帮助我达到以下效果:
http://allegro.pl/doris-wozek-dla-lalek-3f-nosidlo-torba-posciel-15k-i6735944795.html-DORISWÓZEKDLA LALEK 3FNOSIDŁOTORBAPOŚCIEL15K
http://allegro.pl/sukienka-ubranko-dla-lalki-barbie-de-lux-i6739976160.html-Sukienka ubranko dla lalki芭比娃娃!德卢克斯!
HTML搜索结果:
<article class="item__item__2lO83 ">
<div class="vela__item__1FnoI">
<div class="vela__item__details__1di9R">
<div class="photo__thumbnail__1SaYl ">
<noscript>
<i><img src="https://1.allegroimg.com/s128/0166b6/964534be46848305f499770a74f1" alt="DORIS WÓZEK DLA LALEK 3F NOSIDŁO TORBA POŚCIEL 15K" /></i>
</noscript>
</div>
<h2 class="header__title__2RWO4">
<a href="http://allegro.pl/doris-wozek-dla-lalek-3f-nosidlo-torba-posciel-15k-i6735944795.html">DORIS WÓZEK DLA LALEK 3F NOSIDŁO TORBA POŚCIEL 15K</a>
</h2>
</div>
</div>
</article><article class="item__item__2lO83 ">
<div class="vela__item__1FnoI">
<div class="vela__item__details__1di9R">
<div class="photo__thumbnail__1SaYl ">
<noscript>
<i><img src="https://e.allegroimg.com/s128/0129ef/ec0ceef742ce9cdecbe3465a67fe" alt="Sukienka ubranko dla lalki Barbie! DE LUX!" /></i>
</noscript>
</div>
<h2 class="header__title__2RWO4">
<a href="http://allegro.pl/sukienka-ubranko-dla-lalki-barbie-de-lux-i6739976160.html">Sukienka ubranko dla lalki Barbie! DE LUX!</a>
</h2>
</div>
</div>
</article>
最佳答案
在print (item)
中,您正在打印WebElement
to_string()
方法。要打印文字,请使用
print (item.text)