Вы находитесь на странице: 1из 2

# coding: utf-8

# In[1]:

from urllib.request import urlopen as uReq


from bs4 import BeautifulSoup as soup

# In[2]:

my_url = 'https://www.newegg.com/Video-Cards-Video-Devices/Category/ID-
38?Tpk=graphics%20CARD'
uClient = uReq(my_url)
page_html = uClient.read()
uClient.close()

# In[5]:

page_soup = soup(page_html,"html.parser")
containers = page_soup.findAll('div', {"class":"item-container"})

# In[6]:

filename = "test.csv"
f = open(filename,"w")

# In[7]:

for container in containers:


brand = container.div.div.a.img["title"]
print("brand:"+brand)

# In[8]:

title_container = container.findAll("a", {"class":"item-title"})

# In[9]:

product_name = title_container[0].text

# In[12]:
print("Name:"+product_name+"/n")

# In[14]:

price_container = container.findAll("li", {"class":"price-current"})


price = price_container[0].text

# In[15]:

print("price:"+price)

Вам также может понравиться