Skip to content

Instantly share code, notes, and snippets.

@bahrammp
Created August 6, 2018 15:11
Show Gist options
  • Save bahrammp/32417bee2122dc33c9bac60fe8e5ee93 to your computer and use it in GitHub Desktop.
Save bahrammp/32417bee2122dc33c9bac60fe8e5ee93 to your computer and use it in GitHub Desktop.
def get_restaurants_list(page=1):
global counter
http = urllib3.PoolManager()
base_api_url = 'https://www.snappfood.ir/restaurant/?page={}'
r = http.request('GET', base_api_url.format(page))
soup = BeautifulSoup(r.data.decode('utf-8'),'lxml')
restaurant_links = soup.find_all('div',class_='kk-pp-title')
res = list()
for i in restaurant_links:
res.append(i.find_all('a')[0]['href']) # get link of restaurant's page
counter+=1
print(counter)
return res;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment