import requests from bs4 import BeautifulSoup def get_page(url): response = requests.get(url) if not response.ok: print('Server Responded: ', response.status_code) else: soup = BeautifulSoup(response.text, 'lxml') return soup def get_detail_data(soup): #price #item h1 = soup.find('h1', id='itemTitle') print(h1) def main(): url = "https://www.ebay.com/itm/New-Longines-Master-Collection-Automatic-40mm-White-Mens-Watch-L2-909-4-78-3/383525040495?hash=item594bdfb16f:g:vdIAAOSwytheqbKu" get_detail_data(get_page(url)) if __name__ == '__main__': main()
привет, пожалуйста, помогите мне с выбором названия элемента на e-bay. Название предмета - это название часов. Мне удалось добраться до элемента itemTitle.
Пример
import requests from bs4 import BeautifulSoup def get_page(url): response = requests.get(url=url) if not response.ok: print('Server Responded: ', response.status_code) else: soup = BeautifulSoup(response.text, features='html.parser') return soup def get_detail_data(soup): h1 = soup.select("span.g-hdn")[0] print(h1.next_sibling) return h1 if __name__ == "__main__": url = "https://www.ebay.com/itm/New-Longines-Master-Collection-Automatic-40mm-White-Mens-Watch-L2-909-4-78-3/383525040495?hash=item594bdfb16f:g:vdIAAOSwytheqbKu" get_detail_data(get_page(url))
Распечатывает
New Longines Master Collection Automatic 40mm White Men's Watch L2.909.4.78.3