Guest User

Untitled

a guest
Jun 6th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. import bs4
  2. from urllib.request import urlopen as uReq
  3. from bs4 import BeautifulSoup as soup
  4. import mysql.connector
  5.  
  6. cnx = mysql.connector.connect(user='root', password='Kradz579032!!',
  7. host='127.0.0.1',
  8. database='aliexpressapidb')
  9. cursor = cnx.cursor()
  10.  
  11. add_data = ("INSERT INTO productdetails"
  12. "(description) "
  13. "VALUES (%s)")
  14.  
  15. my_url = 'https://www.aliexpress.com/item/Cheap-Necklace-Jewelry-Alloy-Men-Vintage-Personality-Pendant-Creativity-Simple-Accessories-Symbol-Necklace-Wholesale-Fashion/32879629913.html?spm=a2g01.11147086.layer-iabdzn.4.4a716140Ix00VA&scm=1007.16233.91830.0&scm_id=1007.16233.91830.0&scm-url=1007.16233.91830.0&pvid=acdbf117-c0fb-458f-b8a9-ea73bc0d174b'
  16. uClient = uReq(my_url)
  17. page_html = uClient.read()
  18. uClient.close()
  19. page_soup = soup(page_html, "html.parser")
  20. description = page_soup.findAll("div", {"class": "ui-box-body"})
  21. #print(description)
  22. data_insert = description
  23. cursor.execute(add_data, data_insert)
  24.  
  25.  
  26.  
  27.  
  28. cnx.commit()
  29.  
  30. cursor.close()
  31. cnx.close()
Add Comment
Please, Sign In to add comment