#!/usr/bin/env python
# -*- coding: utf-8 -*-
import requests
from bs4 import BeautifulSoup
import csv
import re
def get_html(url):
r = requests.get(url)
# return html code of URL
return r.text
def get_total_pages(html):
soup = BeautifulSoup(html, 'lxml')
pages = soup.find('div', class_='ui-pagination').find_all('a', class_='page-next ui-pagination-next')[-1]
total_pages = pages.split('/')[5].split('.')[0]
return int(total_pages)
def get_page_data():
def main():
url = 'https://ru.aliexpress.com/af/flash%252B32%252Bgb/3.html?isAffiliate=y&initiative_id=AS_20170204114829&site=rus&SearchText=flash+32+gb&tc=af&CatId=202001176'
base_url = 'https://ru.aliexpress.com/af/flash%252B32%252Bgb/'
dynamic_part = ''
query_part = '.html?isAffiliate=y&initiative_id=AS_20170204114829&site=rus&SearchText=flash+32+gb&tc=af&CatId=202001176'
total_pages = get_total_pages(get_html(url))
for i in range(1,3):
url_gen= base_url + dynamic_part + str(i) + query_part
print(url_gen)
# Создание точки входа в программу
if __name__ == ' __main__ ':
main()
Ошибка :
File "newparse.py", line 35
def main():
^
IndentationError: expected an indented block