I am currently working on a script that pulls info from this page.
I want to pull the alt
of each item which I have successfully done with:
image = soup.find_all('img')
for i in image:
print(i['alt'])'
which just gets me the code I need for those 'Item's. I also want to be able to find the name of these items and .append
them to the code (so I can know which code belongs to which 'Item')
But I cannot find the name of the item in the html of the shop page with "all" (which is what I am currently downloading with urllib2
read()
), you can only find the name of the Item
in the category or when you click on the item and the size selection and add to cart button appears.
I want to print the 'Item' code along with the Item name and color (all together). Im thinking of creating all the different urls for each category, and finding all the information that way, but that would take me a while.
I was wondering if anyone would be able to help me out, and provide me with a quick and easy script I could use to perform these tasks with.
I am using python 2.7
, bs4
, and urllib2
I have attempted this script aswell can anyone tell me why it does not work I have been trying to fix it for hours
from bs4 import BeautifulSoup as bs
import urllib2
URL1 = ('http://www.supremenewyork.com/shop/all/jackets')
sauce1 = urllib2.urlopen(URL1).read()
soup1 = bs(sauce1,'lxml')
for name1 in soup1.find_all(attrs={'class':'name-link'}):
image1 = soup1.find_all('img')
for i in image1:
code1 = (i['alt'])+ ' '+(name1.text)
print(code1)
(not sure why the indents arent correct on here But the script executes the name1.text
perfectly but then the i['alt']
ALWAYS prints the last word that it can find so it ends up being like this
Bxvxpc8 dng
Supreme®/Nike®/NBA Teams Warm-Up Jacket
Bxvxpc8 dng Denim
Bxvxpc8 dng Supreme®/Nike®/NBA Teams Warm-Up Jacket
Bxvxpc8 dng White
Bxvxpc8 dng Supreme®/Nike®/NBA Teams Warm-Up Jacket
Bxvxpc8 dng Black
Bxvxpc8 dng
Washed Work Trench Coat
Bxvxpc8 dng
Floral
Bxvxpc8 dng
Washed Work Trench Coat
Bxvxpc8 dng Dusty Teal
Bxvxpc8 dng
Washed Work Trench Coat
Bxvxpc8 dng Black
Bxvxpc8 dng Washed Work Trench Coat
Bxvxpc8 dng White
I have tried switching the two variables around but then it prints the last color it can find and the code works fine help me please