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()
Asked
Active
Viewed 65 times
1
1 Answers
0
Example
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))
Prints out
New Longines Master Collection Automatic 40mm White Men's Watch L2.909.4.78.3

0m3r
- 12,286
- 15
- 35
- 71
-
what if I want "New Longines Master Collection Automatic 40mm White Men's Watch L2.909.4.78.3"? – Kipkurui May 05 '20 at 00:54
-
I am getting "Details about New Longines Master Collection Automatic 40mm White Men's Watch L2.909.4.78.3." How do I extract "New Longines Master Collection Automatic 40mm White Men's Watch L2.909.4.78.3." – Kipkurui May 05 '20 at 08:45
-
sorry I have been little busy - see updated answer- – 0m3r May 11 '20 at 19:31
-
what resources can you recommend inorder to sharpen my skills? – Kipkurui May 12 '20 at 15:27
-
https://stackoverflow.com/a/61467369/4539709 - see this answer it has link @H-petes let me know – 0m3r May 12 '20 at 19:33
-
Please help me extract price @0m3r – Kipkurui May 22 '20 at 10:00
-
Post new question please , I will try to help you – 0m3r May 24 '20 at 03:01