GithubHelp home page GithubHelp logo

Comments (13)

longxiaofei avatar longxiaofei commented on June 12, 2024

#12
You may need to write a correct cookie in "config.py"

from spider-baiduindex.

franklili3 avatar franklili3 commented on June 12, 2024

How can I get cookie? I don't understand the method in Readme.MD.

from spider-baiduindex.

franklili3 avatar franklili3 commented on June 12, 2024

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.

longxiaofei avatar longxiaofei commented on June 12, 2024

click "Fn + F12" -> click "Network" -> refresh page -> click "www.baidu.com" -> copy cookie in "Request Headers"

from spider-baiduindex.

franklili3 avatar franklili3 commented on June 12, 2024

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.

longxiaofei avatar longxiaofei commented on June 12, 2024

你登录了没有?

from spider-baiduindex.

franklili3 avatar franklili3 commented on June 12, 2024

刚才没登录,现在我登录了,又复制了一次,[截图](https://kdocs.cn/l/sAFLdTlxD
[金山文档] cookie.docx),又执行了一次,还是这个错误。

from spider-baiduindex.

longxiaofei avatar longxiaofei commented on June 12, 2024

不介意的话,将全部new_spider_without_selenium下的代码(config.py包含登录的Cookie)发给我,Email: [email protected]

from spider-baiduindex.

franklili3 avatar franklili3 commented on June 12, 2024

发了,请查收,谢谢。

from spider-baiduindex.

longxiaofei avatar longxiaofei commented on June 12, 2024

我这边使用你的Cookie运行没有任何问题,但是demo.py中pandas相关代码有些bug,请自己查改。

from spider-baiduindex.

WowBaiye avatar WowBaiye commented on June 12, 2024

我也遇到了你这个问题,是没有登录所以才会出现这种问题

from spider-baiduindex.

WowBaiye avatar WowBaiye commented on June 12, 2024

建议使用IE浏览器刷cookie,我用chrome,刷新好多次都没刷出来

from spider-baiduindex.

yuyangyoung avatar yuyangyoung commented on June 12, 2024

vscode运行会报错,用其他的IDE就好了

from spider-baiduindex.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.