Skip to content

Instantly share code, notes, and snippets.

@kirussian911
Created September 5, 2018 21:50
Show Gist options
  • Save kirussian911/a6b29e55572222c5d067fef669c96efb to your computer and use it in GitHub Desktop.
Save kirussian911/a6b29e55572222c5d067fef669c96efb to your computer and use it in GitHub Desktop.
from bs4 import BeautifulSoup
import csv
import urllib.request
url = 'https://aliholic.com/shop/'
def get_html(url):
response = urllib.request.urlopen(url)
return response.read()
def get_data(html):
soup = BeautifulSoup(html, 'lxml')
table = soup.find('div', {'class': 'blog-grid-wrap'})
projects = []
for row in table.find_all('article'):
cols = row.find_all('div', {'class': 'hentry-middle'})
projects.append({'title': cols[0].a.text,
'old_price':[old_price.text for old_price in cols[0].div.find_all('del')],
'price':[price.text for price in cols[0].div.find_all('ins')]})
return projects
def main():
print(get_data(get_html(url)))
if __name__=="__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment