taspinar / twitterscraper

Scrape Twitter for Tweets
MIT License
2.39k stars 581 forks source link

Where can I edit the code #314

Closed AbdullaRifai closed 4 years ago

AbdullaRifai commented 4 years ago

Hello, I am trying to do something like this

python twitterscraper.py Trump -l 1000 -bd 2017-01-01 -ed 2017-06-01 -o tweets.json (executing a local version of twitterscraper that I edited)

rather than: twitterscraper Trump -l 1000 -bd 2017-01-01 -ed 2017-06-01 -o tweets.json

which file should come after the "python" to give me this result. Sorry might seem stupid to many of you but I was unable to find it.

lapp0 commented 4 years ago

recommended steps:

python3 -m venv .venv
source .venv/bin/activate
python3 setup.py install
twitterscraper Trump -l 1000 -bd 2017-01-01 -ed 2017-06-01 -o tweets.json
AbdullaRifai commented 4 years ago

@lapp0 thanks for the reply, I think I found it was an exe file, I just wanted to add a simple try, catch to stop me from crashing after 1300 tweets retrieved (Everytime I run) Getting the following error on Windows 10, python 3.7.6:

command:

twitterscraper "(Corona OR Covid) lang:en until:2020-06-09 since:2020-03-13 -filter:links filter:replies" -o new2.json
ERROR: An unknown error occurred! Returning tweets gathered so far.
Traceback (most recent call last):
  File "c:\users\rifai\anaconda3\lib\site-packages\twitterscraper\query.py", line 173, in query_tweets_once_generator
    new_tweets, new_pos = query_single_page(query, lang, pos)
  File "c:\users\rifai\anaconda3\lib\site-packages\twitterscraper\query.py", line 100, in query_single_page
    html = json_resp['items_html'] or ''
KeyError: 'items_html'
INFO: Got 13648 tweets for (Corona%20OR%20Covid)%20lang%3Aen%20until%3A2020-06-09%20since%3A2020-03-13%20-filter%3Alinks%20filter%3Areplies%20since%3A2019-09-25%20until%3A2020-06-11.
INFO: Got 13648 tweets (13648 new).

Edit: Can it possibly mean that that's all the available tweets in the time frame? Thanks in advance.

lapp0 commented 4 years ago

This keyerror appears to be a new problem (oldest mention is 5 days ago) https://github.com/taspinar/twitterscraper/issues/309

Regarding windows development, I'm not quite sure, not experienced in Windows development at all. There are two things I can propose: 1) Install WSL to run python in a linux environment within windows 2) Use Docker

Please let me know if you have any questions or need further help.

AbdullaRifai commented 4 years ago

@lapp0 i see so the issue was brought up before, thanks for your help.