python3.6 安装builtwith模块

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
  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值