0

I am trying to make an exe file with -py2exe Here is my code:

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')])

and this is my setup.py file - from distutils.core import setup import py2exe

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

)

i get the following error in log file after compilation:

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

i run in cmd n python setup.py py2exe

i have no idea how to fixed it. The problem is connected with lxml , but i had add it to my setup modules. Please help

egorkh
  • 478
  • 8
  • 24
  • 1
    Does it work as expected if you change lxml for html.parser? – Dan-Dev Aug 11 '17 at 20:39
  • Thanks i had changed to html.parser and all worked . But i'd like to know why this error has happened – egorkh Aug 12 '17 at 10:20
  • 1
    html.parser is inbuilt in BS4 so if you have BS4 it will work. lxml requires a binary distribution of libxml2 and libxslt.it also requires Visual C++ 2008 redistributables for your version of Windows and PC architecture – Dan-Dev Aug 12 '17 at 10:25

0 Answers0