Comments (13)
#12
You may need to write a correct cookie in "config.py"
from spider-baiduindex.
How can I get cookie? I don't understand the method in Readme.MD.
from spider-baiduindex.
I have opened baidu.com, click Fn + F12, click console tab, write "copy(document.cookie)" and enter, and click Ctrl+C, I have seen the cookie of baidu.com, I have copyed the cookie to COOKIES in config.py. And after I ran demo.py, the error still was "TypeError: string indices must be integers". What can I do ?
from spider-baiduindex.
click "Fn + F12" -> click "Network" -> refresh page -> click "www.baidu.com" -> copy cookie in "Request Headers"
from spider-baiduindex.
I have opened baidu.com, click Fn + F12, click "Network" -> refresh page -> click "www.baidu.com" in Name -> copy cookie in "Request Headers" of Headers. [ScreenShot](https://kdocs.cn/l/sAFLdTlxD
[金山文档] cookie.docx).
I have copyed the cookie to COOKIES in config.py. And after I ran demo.py,
`from get_index import BaiduIndex
import pandas as pd
if name == "main":
keywords = ['比特币']
baidu_index = BaiduIndex(keywords, '2013-04-01', '2013-04-30')
baidu_index_all = pd.DataFrame(columns={'keyword', 'type', 'date', 'index'})
for index in baidu_index.get_index():
if index['type'] == 'all':
index_df = pd.DataFrame(index)
baidu_index_all.append(index_df)`
TypeError Traceback (most recent call last)
g:\zwrk\spider-BaiduIndex\new_spider_without_selenium\demo.py in
7 baidu_index = BaiduIndex(keywords, '2013-04-01', '2013-04-30')
8 baidu_index_all = pd.DataFrame(columns={'keyword', 'type', 'date', 'index'})
----> 9 for index in baidu_index.get_index():
10 if index['type'] == 'all':
11 index_df = pd.DataFrame(index)g:\zwrk\spider-BaiduIndex\new_spider_without_selenium\get_index.py in get_index(self)
56 start_date=params_data['start_date'],
57 end_date=params_data['end_date'],
---> 58 keywords=params_data['keywords']
59 )
60 key = self._get_key(uniqid)g:\zwrk\spider-BaiduIndex\new_spider_without_selenium\get_index.py in _get_encrypt_datas(self, start_date, end_date, keywords)
107 html = self._http_get(url)
108 datas = json.loads(html)
--> 109 uniqid = datas['data']['uniqid']
110 encrypt_datas = []
111 for single_data in datas['data']['userIndexes']:TypeError: string indices must be integers
What can I do ?
from spider-baiduindex.
你登录了没有?
from spider-baiduindex.
刚才没登录,现在我登录了,又复制了一次,[截图](https://kdocs.cn/l/sAFLdTlxD
[金山文档] cookie.docx),又执行了一次,还是这个错误。
from spider-baiduindex.
不介意的话,将全部new_spider_without_selenium下的代码(config.py包含登录的Cookie)发给我,Email: [email protected]
from spider-baiduindex.
发了,请查收,谢谢。
from spider-baiduindex.
我这边使用你的Cookie运行没有任何问题,但是demo.py中pandas相关代码有些bug,请自己查改。
from spider-baiduindex.
我也遇到了你这个问题,是没有登录所以才会出现这种问题
from spider-baiduindex.
建议使用IE浏览器刷cookie,我用chrome,刷新好多次都没刷出来
from spider-baiduindex.
vscode运行会报错,用其他的IDE就好了
from spider-baiduindex.
Related Issues (20)
- BaiduIndex.get_index()报错 HOT 1
- 用老代码,突然指数变为:暂无数据 HOT 11
- 每次只能搜索五个关键词吗?能否扩充呢? HOT 8
- 存储到本地 HOT 1
- 【教程】|百度搜索指数例子中的时间间隔为1天,如何将时间间隔改为半年或一年?
- 【教程】我似乎发现一个bug,爬虫时长跨度超过300天,在300天这点重复该关键词查询602次
- Bad Request HOT 5
- 通过手机扫码登陆,扫描到的一瞬间程序报错QdataError: 百度登录失败 HOT 1
- 提供查询周、月、年平均百度指数的尝试。 HOT 1
- 关于 'ERROR-10003: 网络错误' 建议 HOT 2
- 百度品牌指数和品牌搜索指数 HOT 2
- 账号限制查询 HOT 2
- 百度指数填入cookie后仍提示cookie失效
- 或许可以考虑做一个识别cookies是否有效机制?
- 百度的搜索好像不太好用了 HOT 3
- 账号登录是不是要去解析他的js对密码的加密? HOT 1
- 登录获取dbuss的时候返回channel_v中发现可能没有指定内容,从而报错,建议增加循环获取 HOT 1
- 获取uniqid的时候报错
- 如何获取2010年之前的数据 HOT 1
- 爬了几次,现在出现了安全验证,这个怎么搞呀? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spider-baiduindex.