mozilla

Python爬虫实战之爬取链家广州房价_01简单的单页爬虫

冷暖自知 提交于 2019-12-08 22:38:26
思路介绍 爬取链家广州所有小区信息、在售楼盘及所有历史成交记录,对于超过100个页面的信息,采用曲线爬取的方式,先爬每个小区,然后爬每个小区的在售楼盘及成交记录,后期将进行相应更新,进一步研究Cookie的使用、Proxy(代理)的设置、模拟登录、验证码识别等问题。环境基于Python 2.7。 请求 这里我使用的package是urllib和urllib2,这里列一下爬取过程中需要注意的一些问题。 - 模拟浏览器的行为,设置headers。 - Python 2.x中常见的字符编码和解码问题 首先了解一下字节、字符和编码的关系,ASCII、Unicode和UTF-8的关系,ASCII码一共规定了128个字符的编码,Unicode是一个符号集,只规定了符号的二进制代码,没有规定此二进制代码应该如何存储,结果出现Unicode的多种存储方式,即有许多种不同的二进制格式,可以用来表示Unicode。而UTF-8就是目前使用最广的一种Unicode的实现方式。 Python 2.x里有两种类型的字符串类型:字节字符串和Unicode的字符串。Python根据电脑默认的locale设置将字节转换为字符。 # 获取系统默认的编码方式 <<< import sys <<< print sys.getdefaultencoding() 'ascii' # windows默认的编码是ascii #

爬虫系列之链家的信息爬取及数据分析

假装没事ソ 提交于 2019-12-08 22:32:38
关于链家的数据爬取和分析 已经实现 1.房屋数据爬取并下载 2.房屋按区域分析 3.房屋按经纪人分析 4.前十经纪人 5.经纪人最有可能的位置分析 6.实现以地区划分房屋 目前存在的问题: 1.多线程下载的时候会出现个别文件不继续写入了(已经解决) 2.未考虑经纪人重名问题 3.查询中发现不是每次都能 get 到 url 的数据,具体原因可能跟header有关,或者网站反扒(已经解决,手机端的header有时候访问pc端会出现None的情况) 4.守护线程那里应该出问题了,如果有文件储存完成,其他就不运行了(已经解决,多线程下还要有主程序运行,否则会出现问题) 5.json.dumps(dict)方法取出的字符串类型,二进制的,decode不好用,怎么解决 (已经解决json.dumps(content, ensure_ascii=False)保持原有的编码) 1 # -*- coding: utf-8 -*- 2 # @Time :2018/5/1 23:39 3 # @Author : ELEVEN 4 # @File : _链家_数据分析_修改.py 5 # @Software: PyCharm 6 7 import time 8 from lxml import etree 9 from urllib import request 10 import threading

链家数据爬取+地图找房

旧时模样 提交于 2019-12-08 22:27:57
一、链家数据爬取 (由于链家二手房搜索结果有100页的限制,也就是只能搜到3000条结果,因此,我将按照城区搜索结果进行爬取) 首先从搜索结果页面获得二手房详情页面的url,存储到apartment_url.csv中 # -*- coding: utf-8 -*- import csv import re import urllib2 import sqlite3 import random import threading from bs4 import BeautifulSoup import sys reload(sys) sys.setdefaultencoding("utf-8") #Some User Agents hds=[{'User-Agent':'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.6) Gecko/20091201 Firefox/3.5.6'},\ {'User-Agent':'Mozilla/5.0 (Windows NT 6.2) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.12 Safari/535.11'},\ {'User-Agent':'Mozilla/5.0 (compatible; MSIE 10.0

如何高效地爬取链家的房源信息(一)

ぃ、小莉子 提交于 2019-12-08 22:26:18
“ Python实现的 链家网站的爬虫第一部分。 ” 在之前的文章,以链家成都站为例,分析过链家网站数据的爬取,文章如下: 干货!链家二手房数据抓取及内容解析要点 但是,当时没有根据分析,将爬取实现。 本系列文将以链家南京站为例,使用Python实现链家二手房源信息的爬虫,将数据爬取,并存入数据库中,以便使用。 本文是第一部分,是整个爬取的基础,包括爬取逻辑、伪装正常访问、数据库设计及封装、区域URL爬取四个部分。 01 — 爬取逻辑 本文爬取的地区站虽与之前分析的地区站不同,但二者的结构是一样的,之前分析的成果可以直接套用。 根据之前的分析成果,得到爬取流程如下: 第一步,找到爬取站点的地址,这里爬取的是南京站,为https://nj.lianjia.com/。 第二步,从二手房查询页面获取大区信息,以便后续的查询。 这样的好处是可以分区查询,避免单次数据太多,链家服务器无法返回全部内容,最终导致数据不全。 第二步,根据分区信息,获取小区信息,存数据库,后续爬取操作,均以小区信息为起点。 第三步,根据各个小区信息,获取该小区的所有在售房源信息,存数据库。 第四步,根据 各个小区信息, 获取该小区的所有成交房源信息,存数据库。 确定了爬取流程,也就确定了程序的基本框架,接下来我们还需要准备相关Python库,数据库——sqlite3,以及分析网页库——BeautifulSoup

python爬取小猪租房网站(结果保存为csv文件)

我怕爱的太早我们不能终老 提交于 2019-12-08 21:51:33
我们这里多创建几个user-agent和referer这样可以有效隐藏身份 import csv import random import time import requests from lxml import html import re class SPS(): def __init__(self): self.listUrl = [] self.flag = True self.ua = [ 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36' , 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.163 Safari/535.1' , 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0) Gecko/20100101 Firefox/6.0' , 'Opera/9.80 (Windows NT 6.1; U; zh-cn) Presto/2.9.168 Version/11.50' , 'Mozilla/5.0

window.onload function doesn't work on Mozilla Firefox

别说谁变了你拦得住时间么 提交于 2019-12-08 17:23:08
问题 I'm using a loading screen for a webpage and I use window.onload function. Everything works great except in Mozilla Firefox browsers. When we first visit or refresh the page with ctrl+F5 combination, the loading screen never disappears. if we refresh the page only with F5, then it works. I use the code below $(window).load(function(e) { $("#body-mask").fadeOut(1000,function(){ $(this).remove(); }); }); I have also tried the code below but nothing changed. window.onload = function () { $("

Firefox 38-40 SMIL problems - very slow speed (resolved in FF version 41 from 22.09.15)

自古美人都是妖i 提交于 2019-12-08 13:50:17
问题 Can you give some information about new versions FF, that passed after version 37.0.2. I knew that most of the bugs in version 38 have been fixed in version 38.0.5. I noticed a difference in the processing speed of the attributes 'animate' and 'animateTransform' in all new versions of FF, and because of this the page becomes really slow. If remove animate tags: <rect x="-1.32" y="-0.63" width="3.64" height="1.26" fill="#FFD9D9" stroke-width="0.0" rx="0.12"> <!--this animation makes half

Changing border-color on selection

我的未来我决定 提交于 2019-12-08 09:48:34
问题 I'm trying to modify the default selection styles by using the ::selection and ::-moz-selection pseudoelements. I've successfully changed the selection color and background with these two rules: ::-moz-selection{ background: #444; color:#fff; text-shadow: none; } ::selection { background:#444; color:#fff; text-shadow: none; } However, I also need to change the border-color to white on selection for links. I'm trying to accomplish this with this CSS: a::-moz-selection { border-color:#FFF;} a:

Mozilla form.submit() not working

谁说我不能喝 提交于 2019-12-08 08:26:37
问题 I am creating a dynamic form using following code, function createForm() { var f = document.createElement("form"); f.setAttribute('method',"post"); f.setAttribute('action',"./Upload"); f.setAttribute('name',"initiateForm"); f.acceptCharset="UTF-8"; var name = document.createElement("input"); name.setAttribute('type',"text"); name.setAttribute('name',"projectname"); name.setAttribute('value',"saket"); f.appendChild(name); f.submit(); } But in Mozilla nothing happens but code works as expected

overflow-y: scroll not working in firefox

拟墨画扇 提交于 2019-12-08 08:15:35
问题 Kindly refer to URL : http://jsfiddle.net/8tFnG/1/ <table border="1" cellspacing="0" cellpadding="1" width="100%"> <colgroup> <col span="1" style="width:5%"> <col span="1" style="width:70%"> <col span="1" style="width:25%"> </colgroup> <tr> <td colspan="2"> <div style="width:100%; box-shadow: 1px 1px 1px #cfcfcf; border-radius:10px; color:black; border:1px solid #e5e5e5; min-height: 100px;">Sample Text 1</div> </td> <td rowspan="5" style="vertical-align: top;"> <section class="loginform">