python 未知
import time
import requests
from bs4 import BeautifulSoup
import threading def format_str(s):
return s.replace("\n","").replace("","").replace("\t",'') def get_urls_in_pages(from_page_num,to_page_num):
urls=[]
search_word='计算机'
url_part_1='http://www.phei.com.cn/moudle/goods/'\
'searchkey.jsp? Page='
url_part_2='&Page=2&searchKey='
for i in range(from_page_num,to_page_num+1):
urls.append(url_part_1
+str(i)+
url_part_2+search_word)
all_href_list=[]
for url in urls:
print(url)
resp=requests.get(url)
bs=BeautifulSoup(resp.text)
a_list=bs.find_all('a')
needed_list=[]
for a in a_list:
if 'href'in a.attrs:
href_val=a['href']
title=a.text
if 'bookid'in href_val and 'shopcar0.jsp'\
not in href_val and title !='':
if [title,href_val] not in needed_list:
needed_list.append([format_str(title),
format_str(href_val)])
all_href_list+=needed_list
all_href_file=open(str(from_page_num)+'_'+
str(to_page_num)+'_'+
'all_hrefs.txt','w')
for href in all_href_list:
all_href_file.write('\t'.join(href)+'\n')
all_href_file.close()
print(from_page_num,to_page_num,len(all_href_list))
python 未知的更多相关文章
- python未知网卡名情况下获取本机IP
import socket def get_ip(): s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) try: # doesn't even ...
- ######【Python】【基础知识】【一些未知的知识点】######
在查资料.看书过程中遇到的一些未知的领域.知识点: 1.模仿静态变量 可参考: https://www.runoob.com/python/python-exercise-example41.html ...
- 在python学习时间过程中,你会不断发现需要解决的问题,更多需要连接未知,这时候到哪里去查阅资料呢?
1.safari online book https://www.safaribooksonline.com 知乎上有人问,送程序员什么礼物好,其中一个答案就是safari online.编程的英文书 ...
- python了解未知函数的方法
?func 如图:
- Python标准模块--Unicode
1 模块简介 Python 3中最大的变化之一就是删除了Unicode类型.在Python 2中,有str类型和unicode类型,例如, Python 2.7.6 (default, Oct 26 ...
- 字符型图片验证码识别完整过程及Python实现
字符型图片验证码识别完整过程及Python实现 1 摘要 验证码是目前互联网上非常常见也是非常重要的一个事物,充当着很多系统的 防火墙 功能,但是随时OCR技术的发展,验证码暴露出来的安全问题也越 ...
- 利用Python进行数据分析(2) 尝试处理一份JSON数据并生成条形图
一.JSON 数据准备 首先准备一份 JSON 数据,这份数据共有 3560 条内容,每条内容结构如下: 本示例主要是以 tz(timezone 时区) 这一字段的值,分析这份数据里时区的分布情况. ...
- Windows下Python中pip安装Pillow报错总结(转载)
遇到的俩种错误1.ValueError: zlib is required unless explicitly disabled using --disable-zlib, aborting 问题原因 ...
- 1 python大数据挖掘系列之基础知识入门
preface Python在大数据行业非常火爆近两年,as a pythonic,所以也得涉足下大数据分析,下面就聊聊它们. Python数据分析与挖掘技术概述 所谓数据分析,即对已知的数据进行分析 ...
随机推荐
- ocpm
学习中心 | 腾讯社交广告营销平台 http://e.qq.com/ads/learning/data/optimization/case/035/
- atcoder 076
日本人的比赛 C:如果两个数差了大于1无解,否则分类讨论 #include<bits/stdc++.h> using namespace std; typedef long long ll ...
- Rails5 Controller Document
更新: 2017/06/28 大致完成全部 更新: 2017/06/29 补充module文件命名规则 更新: 2017/07/09 补充session的设置 更新: 2018/03/06 修正ren ...
- CentOS 7.0 firewall防火墙关闭firewall作为防火墙,这里改为iptables防火墙
CentOS 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙步骤: 1.先检查是否安装了: iptables service iptables status 2.安装ip ...
- python 学习笔记一 (数据结构和算法)
2018年刚刚过完年,从今天起,做一个认真的技术人.开始进入记笔记阶段. python内置了很多数据结构,list , set,dictionary 1.将序列分解为单独的变量 1.1 通过赋值的方式 ...
- JVM 垃圾回收器详解
小结: 新生代 串行Serial 并行 Parallel(关注吞吐量) 并行ParNew 老年代 串行 Serial Old 并行Para ...
- JS——祝愿墙
注意事项: 1.for循环的下一层注册了事件的话,事件函数中关于变量i的节点元素是不允许出现的,因为在函数加载的时候,只会加载函数名,不会加载函数体,外层for循环会走完一边,变量i一直会停留在最后一 ...
- [Windows Server 2008] Apache+PHP安全设置
★ 欢迎来到[护卫神·V课堂],网站地址:http://v.huweishen.com★ 护卫神·V课堂 是护卫神旗下专业提供服务器教学视频的网站,每周更新视频.★ 本节我们将带领大家:Win2008 ...
- oracle sql*loader的使用
用法: SQLLDR keyword=value [,keyword=value,...] 有效的关键字: userid -- ORACLE 用户名/口令 control -- 控制文件 ...
- 【译】x86程序员手册06 - 2.4指令格式
2.4 Instruction Format 指令格式 The information encoded in an 80386 instruction includes a specification ...