zoukankan      html  css  js  c++  java
  • 分布式爬虫(5):微博数据爬取

    一、使用Selenium+Phantoms来抓取数据

        1.登录:最重要的是设置User-Agent,否则无法转跳链接 

    from selenium.webdriver.common.desired_capability import DesiredCapabilities
    user_agent=(
      "Mozilla/5.0()"

    )

        2.输入用户名和密码:

    <input id="loginname"
    type="text"
    class="W input" maxlength="128"
    autocomplete="off"
    action-data="text=........"
    name="username"
    node-type="username" 
    tabindex="1">

        (1)为了与微博内容交互,需要用到javascript

          相关的javascript代码:

          document.getElementById('loginname').value='abc'

          document.getElementsByName('password')[0].value='abc'

          通过Selenium提供的send_keys来进行传递value

          driver.find_element_by_id('loginname').send_keys(username)

          driver.find_element_by_name('password').send_keys(password)

    二、微博接口分析

    三、直接调用微博API来抓取

    四、表单及登录

    四、表单及登录

  • 相关阅读:
    Android 动画-alpha(渐变透明度动画效果)
    Memento(备忘录)
    Mediator(中介者)
    Iterator(迭代器)
    Command(命令)
    Chain of Responsibility(责任链)
    Template Method(模板方法)
    Interpreter(解释器)
    Proxy(代理)
    Flyweight(享元)
  • 原文地址:https://www.cnblogs.com/bigdata-stone/p/9861479.html
Copyright © 2011-2022 走看看