我想从Windows 8和10的Python脚本中创建一个EXE文件,我使用的是python 2.7。我试过py2exe和cx_Freeze,但没有任何效果。我问了一个关于我的问题的问题 - py2exe write data to file not working,但没有人回答过。
import requests
from 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/']
for url in urls:
html = get_html(url)
soup = BeautifulSoup(html, 'html.parser')
mydivs = soup.findAll('a',class_="banners_images")
urls = []
for i 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=[]
with open('/home/arator/1.csv', 'a') as f: # Open the file in binary mode for Python 2.x
f.write(u'\ufeff'.encode('utf8')) # writes "byte order mark" UTF-8 signature
writer = csv.writer(f)
for i 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'] for 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)
有没有人知道让脚本运行的方法?是用哪种简单方法让脚本以另一种方式执行应用程序&