fixed error in making exe file using python 2.7 -
i d make exe file python script windows 8 , 10, using python 2.7. tried py2exe , cx_freeze, nothing has worked. asked question problem -py2exe write data file not working, no 1 had answered it.
!/usr/bin/python2.7
import requests bs4 import beautifulsoup import csv import re def get_html(url): r = requests.get(url) return r.text url2 = 'http://www.autobody.ru/kuzovnoy-remont/' urls1 = ['http://www.autobody.ru/kuzovnoy-remont/'] urls=['http://www.autobody.ru/kuzovnoy-remont/','http://www.autobody.ru/optics/','http://www.autobody.ru/tuning/','http://www.autobody.ru/cooling/','http://www.autobody.ru/mechanics/','http://www.autobody.ru/mirrors/'] url in urls: html = get_html(url) soup = beautifulsoup(html, 'html.parser') mydivs = soup.findall('a',class_="banners_images") urls = [] in mydivs: ur = (i.get('href')) ur = 'http://www.autobody.ru' + str(ur) urls.append(ur.encode('utf8')) images = [] heads = [] artic = [] atrib = [] price = [] a1=[] a2=[] a3=[] open('/home/arator/1.csv', 'a') f: # open file in binary mode python 2.x f.write(u'\ufeff'.encode('utf8')) # writes "byte order mark" utf-8 signature writer = csv.writer(f) in urls: html = get_html(i) soup = beautifulsoup(html, 'html.parser') head = soup.find('h1').get_text() heads.append(head.encode('utf8')) image = [x['src'] x in soup.findall('img', {'class': 'detimg'})] image1 = 'http://www.autobody.ru'+image[0] images.append(image1.encode('utf8')) price1 = soup.find('div', class_='price').get_text() price1 = re.sub(r"c",r"p", price1) price.append(price1.encode('utf8')) zo=soup.find('table', class_='tech').find_all('tr') artic.append(zo[0].get_text().strip().encode('utf8')) atrib.append(zo[1].get_text().strip().encode('utf8')) a1.append(zo[2].get_text().strip().encode('utf8')) try: a2.append(zo[3].get_text().strip().encode('utf8')) except: a2.append(1) writer.writerows(zip(*[heads, price, artic, images,atrib,a1,a2,urls])) print(1)
does knows way make script worked ?is easy way make script exe application in way&
Comments
Post a Comment