Hey Guys i am trying to scrape some data from aliexpress but whenever i want to access any url, it ask me to login before accessing the page.i don't know how to automatically login into website, some of you may use use cookies but i don't know how to use cookies, Here is my code :
import requests
from bs4 import BeautifulSoup
import csv
from selenium import webdriver
g = csv.writer(open('aliexpressnew.csv', 'a',newline='',encoding="utf-8"))
#g.writerow(['Product Name','Price','Category','Subcategory'])
links = [
"https://www.aliexpress.com/category/205838503/iphones.html?spm=2114.search0103.0.0.6ab01fbbfe33Rm&site=glo&g=n&needQuery=n&tag="
]
for i in links:
getlink = i
while getlink != 0:
chromepath = 'C:\\Users\Faisal\Desktop\python\chromedriver.exe'
driver = webdriver.Chrome(chromepath)
driver.get(getlink)
soup = BeautifulSoup(driver.page_source, 'html.parser')
a
if itemsname1.find(class_='img-container left-block util-clearfix').find(class_='img').find(class_='picRind j-p4plog'):
if itemsname1.find(class_='img-container left-block util-clearfix').find(class_='img').find(class_='picRind j-p4plog').find('img').get('src'):
image = itemsname1.find(class_='img-container left-block util-clearfix').find(class_='img').find(class_='picRind j-p4plog').find('img').get('src')
else:
image = itemsname1.find(class_='img-container left-block util-clearfix').find(class_='img').find(class_='picRind j-p4plog').find('img').get('image-src')
else :
if itemsname1.find(class_='img-container left-block util-clearfix').find(class_='img').find(class_='picRind ').find('img').get('src'):
image = itemsname1.find(class_='img-container left-block util-clearfix').find(class_='img').find(class_='picRind ').find('img').get('src')
else:
image = itemsname1.find(class_='img-container left-block util-clearfix').find(class_='img').find(class_='picRind ').find('img').get('image-src')
image3 = 'http:'+ str(image)
print(title)
print(price)
#print(rating2)
print(image3)
g.writerow([title,price,subcat2,image])
next1 = soup.find(class_='ui-pagination-navi util-left')
if next1.find(class_="page-end ui-pagination-next ui-pagination-disabled"):
getlink=0
else:
next22 = next1.find(class_='page-next ui-pagination-next')
next3 = "http:" + next22.get('href')
getlink = next3
driver.close()
