Windows 7

时间:2017-08-11 20:29:21

标签: python-2.7 beautifulsoup lxml py2exe bs4

我正在尝试使用-py2exe创建一个exe文件 这是我的代码:

import requests
from bs4 import BeautifulSoup
import csv

def get_html(url):
    r = requests.get(url)
    return r.text

url='http://rcrealty.ru/catalog/residential/office'


html=get_html(url)
soup=BeautifulSoup(html, 'lxml')
mydivs = soup.findAll('div',class_="properties-list-block")


pages=soup.findAll('a',class_='col-xs-12 col-sm-6 col-md-3 predloj')
z=[]
for page in pages :

     z.append(page.get('href'))



pages=soup.find('a',class_='col-xs-12 col-sm-6 col-md-3 predloj')



pages=soup.findAll('a',class_='col-xs-12 col-sm-6 col-md-3 predloj')
z=[]
for page in pages :

      z.append(page.get('href'))
urls=[]
for i in z:
    ur='http://rcrealty.ru'+str(i)
    urls.append(ur)




titles = soup.findAll('h2',class_="title")
t=[]
for i in titles:
    t.append(i)



texts=[]
for i in urls: 
 z=get_html(i)

 soup=BeautifulSoup(z, 'lxml')

 r=soup.findAll('p')
 texts.append(r[0])

da={'titles': t,'links' :urls,'texts':texts}

with open('C:\\1\\2\\1.txt','wb') as f:
  f.write(u'\ufeff'.encode('utf8')) # writes "byte order mark" UTF-8 signature
  writer=csv.writer(f)
  for i in da:
   for rows in da[i]:
    writer.writerow([rows.encode('utf8')])

这是我的setup.py文件 - 来自distutils.core导入设置 导入py2exe

setup(
    windows=[{"script":"parser_ned.py"}],
    options={"py2exe": {"includes":["bs4","requests","csv","lxml"]}},
    zipfile=None

)

编译后我在日志文件中收到以下错误:

bs4.FeatureNotFound: Couldn't find a tree builder: lxml

我在cmd n python setup.py py2exe

中运行

我不知道如何修复它。问题与lxml有关,但我已将其添加到我的安装模块中。 请帮忙

0 个答案:

没有答案