码迷,mamicode.com
首页 > Windows程序 > 详细

Web_Scraping Techniques

时间:2020-05-22 19:35:17      阅读:74      评论:0      收藏:0      [点我收藏+]

标签:apn   pytho   html   header   zip   apple   web   webkit   load   

 

web_scraping_package.py

from bs4 import BeautifulSoup
import requests
session = requests.Session()
headers = {
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36,
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
}

 

import sys
sys.path

获取python的path

[‘‘, /usr/lib/python36.zip, /usr/lib/python3.6, /usr/lib/python3.6/lib-dynload, /home/christopher/.local/lib/python3.6/site-packages, /usr/local/lib/python3.6/dist-packages, /usr/lib/python3/dist-packages]

 

这里我们把

web_scraping_package.py

放到

/home/christopher/.local/lib/python3.6/site-packages

目录下

 

 

以后就可以直接import

from web_scraping_package import session, headers, BeautifulSoup

 

就不用再写一大串导入文件了。

 

Web_Scraping Techniques

标签:apn   pytho   html   header   zip   apple   web   webkit   load   

原文地址:https://www.cnblogs.com/profesor/p/12938829.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!