#-*- coding:utf-8 -*-

import xlwt
import urllib
import re def getHtml(url):
page = urllib.urlopen(url)
html = page.read()
return html
def get_book_message(url):
page = urllib.urlopen(url)
html = page.read()
urls = []
page.close()
imgReg = r'src="(.+?\.jpg)"'
titlReg = r'rel="bookmark">(.+?)</a>'
divre = re.compile(imgReg)
divreTitle = re.compile(titlReg)
divlist = re.findall(divre,html)
titleList = re.findall(divreTitle,html)
bookMessage = {}
for url,title in zip(divlist,titleList):
bookMessage[title] = url return bookMessage
def run():
value = get_book_message('http://www.allitebooks.com/')
workbook = xlwt.Workbook(encoding = 'ascii')
worksheet = workbook.add_sheet('MyBookMessage')
worksheet.write(0,1,u'地址')
worksheet.write(0,2,u'标题')
index = 1
for x in value:
worksheet.write(index,1,x)
worksheet.write(index,2,value[x])
index = index + 1
workbook.save('MyBookMessage.xls')
run()

Python 爬取图书图片和地址的更多相关文章

  1. Python爬取谷歌街景图片

    最近有个需求是要爬取街景图片,国内厂商百度高德和腾讯地图都没有开放接口,查询资料得知谷歌地图开放街景api 谷歌捷径申请key地址:https://developers.google.com/maps ...

  2. 利用Python爬取网页图片

    最近几天,研究了一下一直很好奇的爬虫算法.这里写一下最近几天的点点心得.下面进入正文: 你可能需要的工作环境: Python 3.6官网下载 我们这里以sogou作为爬取的对象. 首先我们进入搜狗图片 ...

  3. Python 爬取美女图片,分目录多级存储

    最近有个需求:下载https://mm.meiji2.com/网站的图片. 所以简单研究了一下爬虫. 在此整理一下结果,一为自己记录,二给后人一些方向. 爬取结果如图:   整体研究周期 2-3 天, ...

  4. python爬取网页图片(二)

    从一个网页爬取图片已经解决,现在想要把这个用户发的图片全部爬取. 首先:先找到这个用户的发帖页面: http://www.acfun.cn/u/1094623.aspx#page=1 然后从这个页面中 ...

  5. 用python 爬取网页图片

    import re import string import sys import os import urllib url="http://tieba.baidu.com/p/252129 ...

  6. python爬取网页图片

    # html:网页地址 def getImg2(html): soup = BeautifulSoup(html, 'html.parser') href_regex = re.compile(r'^ ...

  7. python爬取百度图片

    import requests import re from urllib import parse import os from threading import Thread def downlo ...

  8. python爬取许多图片的代码

    from bs4 import BeautifulSoup import requests import os os.makedirs('./img/', exist_ok=True) URL = & ...

  9. python 爬取妹子

    爬取妹子图片 网址:https://www.mzitu.com/jiepai/ 2019-06-13 环境WIN10 1903 python 3.7.3 个人习惯先在IDLE中进行调试 import ...

随机推荐

  1. 公司项目git开发流程规范

    手动修改冲突之后,git add . git commit ,git push

  2. sublime text 3 入门技巧与常见问题解决

    1. 常见问题 - 解决sublime 窗口栏(UNREGISTERED)(未购买)导致的经常性弹窗 解决方法: 点击Help -> About Sublime Text,查看sublimete ...

  3. 常用css和js组件

    1 . input框中插入图标 <div class="col-sm-12 col-xs-12 setLineHeight"> <div class=" ...

  4. sshd_config配置注释

    # $OpenBSD: sshd_config,v 1.80 2008/07/02 02:24:18 djm Exp $ # This is the sshd server system-wide c ...

  5. jquery.page.js插件在使用时重复触发“上一页”和“下一页”操作

    jquery.page.js使用demo HTML代码 <div class="result"> <div class="tcdPageCode&quo ...

  6. 洛谷 P1345 [USACO5.4]奶牛的电信Telecowmunication

    题目描述 农夫约翰的奶牛们喜欢通过电邮保持联系,于是她们建立了一个奶牛电脑网络,以便互相交流.这些机器用如下的方式发送电邮:如果存在一个由c台电脑组成的序列a1,a2,...,a(c),且a1与a2相 ...

  7. 3D模型预处理(格式转换:obj转换为gltf)

    在cesium中导入模型需要的是gltf或glb格式的文件,cesium官方提供了obj转gltf文件的工具,一个obj2gltf的库,地址为https://github.com/Analytical ...

  8. event loop、进程和线程、任务队列

    本文原链接:https://cloud.tencent.com/developer/article/1106531 https://cloud.tencent.com/developer/articl ...

  9. IDEA安装及破解

    一.下载(IDEA 2019.1.2) 1.下载地址:https://www.jetbrains.com/idea/download/#section=windows 2.选择版本,并选择最终版(.e ...

  10. 有关SQL的一道面试题

    这是一个学生分数表 StudentName            StudySubject           SubjectScore Peter                           ...