Python之scrapy实现的爬虫,百度贴吧的自动签到和自动发帖、自动回帖
生活随笔
收集整理的這篇文章主要介紹了
Python之scrapy实现的爬虫,百度贴吧的自动签到和自动发帖、自动回帖
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
百度貼吧Crawler
實現百度貼吧的自動簽到和自動發帖、自動回帖
實現Cookies免登錄
實現方式
主要是用了scrapy框架實現爬取,PIL實現現實驗證碼,運行前得先安裝scrapy和PIL。
scrapy安裝方式 scrapy入門教程
PIL使用教程官網中文版
運行方式
? ?運行這個文件 run.py或者用命令方式:
scrapy crawl AutoSign和
scrapy crawl AutoPost? ?
import loggingfrom scrapy import cmdline from scrapy.crawler import CrawlerRunner from scrapy.utils.log import configure_logging from scrapy.utils.project import get_project_settings from twisted.internet import reactorfrom tieba import spidersdef run_auto_sign():cmdline.execute('scrapy crawl AutoSign'.split())def run_auto_post():cmdline.execute('scrapy crawl AutoPost'.split())if __name__ == '__main__':# run_auto_sign()settings = get_project_settings()configure_logging(settings)runner = CrawlerRunner(settings)runner.crawl(spiders.AutoSignSpider)# runner.crawl(spiders.AutoPostSpider)d = runner.join()# noinspection PyUnresolvedReferencesd.addBoth(lambda _: reactor.stop())# blocks process so always keep as the last statement# noinspection PyUnresolvedReferencesreactor.run() logging.info('all finished.')未解決問題
簽到和發帖、回復貼子的人機驗證還未實現。
免責聲明
本項目所提供的信息和技術,只供參考之用。其他人一概毋須以任何方式就任何信息傳遞或傳送的失誤、不準確或錯誤對用戶或任何其他人士負任何直接或間接的責任。任何人不得侵犯百度的任何合法權益,使用者應自行遵守百度相關的用戶協議,不得爬取百度禁止的內容,否則責任自行 承擔,本項目及項目提供者不承擔任何直接或間接的責任。在法律允許的范圍內,本項目在此聲明,不承擔用戶或任何人士就使用或未能使用本項目所提供的信息或任何鏈接或項目 所引致的任何直接、間接、附帶、從屬、特殊、懲罰性或懲戒性的損害賠償(包括但不限于收益、預期利潤的損失或失去 的業務、未實現預期的節省)。本項目所提供的信息,若在任何司法管轄地區供任何人士使用或分發給任何人士時會違反該司法管轄地區的法律或條例的 規定或會導致本項目或其第三方代理人受限于該司法管轄地區內的任何監管規定時,則該等信息不宜在該司法管轄地區供 該等任何人士使用或分發給該等任何人士。用戶須自行保證不會受限于任何限制或禁止用戶使用或分發本項目所提供信息 的當地的規定。本項目圖片,文字之類版權申明,因為項目可以由用戶自行下載修改,本項目無法鑒別所上傳圖片或文字的知識版權,如 果侵犯,請及時通知我們,本項目將在第一時間及時刪除。凡以任何方式下載使用本項目或直接、間接使用本項目資料者,視為自愿接受本項目聲明的約束。License
Copyright ? 2017 CHANGLEI. All rights reserved.Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.轉載于:https://my.oschina.net/u/3405754/blog/1635142
總結
以上是生活随笔為你收集整理的Python之scrapy实现的爬虫,百度贴吧的自动签到和自动发帖、自动回帖的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 解决打开一个excel文件,却出现两个窗
- 下一篇: 灵活操作MS SQL 2005 中的数据