python3跟python2在语法上存在许多不同,而builtwith是用python2写的,所以要对builtwith进行相应的修改才可以用到python3.6里面。具体步骤如下:
1.安装bulitwith模块。
pip install builtwith
在某些windows中会出现以下错误:
command not found
这时需要跳转到pip命令所在的目录执行该命令:
cd ~/python/python36-32/Scripts
或者将该路径添加到系统环境变量里面,就可以在windows命令行下执行安装指令了。
2.修改builtwith模块的init.py文件
如果现在直接导入builtwith模块会出现错误,如下:
>>> import buitwith
>Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
import builtwith
File "C:\Users\moying\AppData\Local\Programs\Python\Python36-32\lib\site-packages\builtwith\__init__.py", line 43
except Exception, e:
^
SyntaxError: invalid syntax
这时就要对builtwith模块进行相应的修改,使其可以通过python3的语法检测,打开builtwith模块的init.py文件,将里面的内容修改成下面的形式:
import sys
import os
import re
import json
import urllib.request
import urllib.error
import chardet
def builtwith(url, headers=None, html=None, user_agent='builtwith'):
"""Detect the technology used to build a website
>>> builtwith('http://wordpress.com')
{u'blogs': [u'PHP', u'WordPress'], u'font-scripts': [u'Google Font API'], u'web-servers': [u'Nginx'], u'javascript-frameworks': [u'Modernizr'], u'programming-languages': [u'PHP'], u'cms