-
-
Notifications
You must be signed in to change notification settings - Fork 267
Description
I had a parsing issue that was temporarly fixed but now is back again. i keep getting this error: 2025-12-16 20:09:04.672 | WARNING | twscrape.queue_client:req:291 - Unknown error. Account timeouted for 15 minutes. Create issue please: https://github.com/vladkens/twscrape/issues If it mistake, you can unlock accounts with twscrape reset_locks. Err: <class 'Exception'>: Failed to parse scripts
This is the part i changed last time and solved the parsing issue for a few days:
Monkey patch for twscrape "Failed to parse scripts" issue
#284
def script_url(k: str, v: str):
return f"https://abs.twimg.com/responsive-web/client-web/{k}.{v}.js"
def patched_get_scripts_list(text: str):
scripts = text.split('e=>e+"."+')[1].split('[e]+"a.js"')[0]
try:
for k, v in json.loads(scripts).items():
yield script_url(k, f"{v}a")
except json.decoder.JSONDecodeError:
# Fix all unquoted keys - more aggressive pattern
fixed_scripts = re.sub(
r'([,\{])(\s*)([a-zA-Z_][a-zA-Z0-9_]*)(\s*):',
r'\1\2"\3"\4:',
scripts
)
for k, v in json.loads(fixed_scripts).items():
yield script_url(k, f"{v}a")
Apply monkey patch before importing twscrape
from twscrape import xclid
xclid.get_scripts_list = patched_get_scripts_list
Anyone else also experiencing the same issue and/or has a solution for this?