Найти - Пользователи
Полная версия: Ошибка синтаксиса.
Начало » Python для новичков » Ошибка синтаксиса.
1
lipenn
Здравствуйте. Помогите исправить ошибку.
Получаю сообщение
 C:\Windows\system32>python C:\Users\Administrator\Desktop\skr.py
Traceback (most recent call last):
  File "C:\Users\Administrator\Desktop\skr.py", line 1, in <module>
    from webscraping import download, alg
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\sit
e-packages\webscraping\__init__.py", line 13
    print name
             ^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(name)?
Выполняется следующий код:
 from webscraping import download, alg
D = download.Download()
html = D.get('http://buklijas.info/')
emails = alg.extract_emails(html)
print("",emails)
JOHN_16
вы видимо руками устанавливали библиотеку?
Проблема в том что у вас питон3 а библиотека написано под питон 2
lipenn
JOHN_16 Спасибо, как можно сделать на питон3 следующее
 from webscraping import download
 
D = download.Download()
 
emails = D.get_emails("http://buklijas.info/", max_depth=2, max_urls=None, max_emails=None)
 
print emails

JOHN_16
lipenn
Вам уже сказали
lipenn
SyntaxError: Missing parentheses in call to ‘print’. Did you mean print(name)?
lipenn
JOHN_16
Это я поняла) Вопрос, как, тоже самое сделать на питон 3. То есть без webscraping.
Установила на другом ервере питон 2.7 Работает скрипт, подскажите где поставить слип чтобы между запросами сделать паузу 1 секунда. Там где сейчас слип, он бесполезен наверное)
 from webscraping import download, alg
from time import sleep
sleep (2)
D = download.Download()
emails = D.get_emails("http://onpoc.ga", max_depth=2, max_urls=2, max_emails=2)
print emails
lipenn
Интересно, если значение параметров ставлю больше двойки здесь, вот так
 emails = D.get_emails("http://onpoc.ga", max_depth=3, max_urls=3, max_emails=3)
то получаю такой вывод
 C:\Users\Administrator>python C:\Users\Administrator\Desktop\skr.py
Downloading http://onpoc.ga/├Р3/4-├Р1/2├Р┬░├С┬Б/
Traceback (most recent call last):
  File "C:\Users\Administrator\Desktop\skr.py", line 9, in <module>
    emails = D.get_emails("http://onpoc.ga", max_depth=3, max_urls=3, max_emails
=3)
  File "C:\Python27\lib\site-packages\webscraping\download.py", line 497, in get
_emails
    return DataCrawler(self, alg.extract_emails).find(website, max_depth, max_ur
ls, max_emails)
  File "C:\Python27\lib\site-packages\webscraping\download.py", line 1093, in fi
nd
    html = self.D.get(url, num_retries=0)
  File "C:\Python27\lib\site-packages\webscraping\download.py", line 235, in get
    html = self.fetch(url, headers=settings.headers, data=settings.data, proxy=s
elf.proxy, user_agent=settings.user_agent, opener=settings.opener, pattern=setti
ngs.pattern, max_size=settings.max_size)
  File "C:\Python27\lib\site-packages\webscraping\download.py", line 442, in fet
ch
    common.logger.warning(u'Download error: {} {} ({})'.format(url, e, self.resp
onse_code))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 16: ordinal
 not in range(128)
C:\Users\Administrator>
Подскажите, что ему нужно
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB