質問するログイン新規登録

質問編集履歴

1

target_urlとscrp.text.split(" = ", 1)[1]

2020/05/21 14:57

投稿

macarooon
macarooon

スコア2

title CHANGED
File without changes
body CHANGED
@@ -18,7 +18,7 @@
18
18
  import json
19
19
  import requests
20
20
 
21
- target_url = "https://www.youtube.com/live_chat_replay?continuation=xxxxxxxx"
21
+ target_url = "https://www.youtube.com/watch?v=xxxxx(取得したい動画のURL)"
22
22
  dict_str = ""
23
23
  next_url = ""
24
24
  comment_data = []
@@ -44,7 +44,7 @@
44
44
  # 次に飛ぶurlのデータがある部分をfind_allで探してsplitで整形
45
45
  for scrp in soup.find_all("script"):
46
46
  if "window[\"ytInitialData\"]" in scrp.text:
47
- dict_str = scrp.text.split(" = ")[1]
47
+ dict_str = scrp.text.split(" = " , 1)[1]
48
48
 
49
49
  # javascript表記なので更に整形. falseとtrueの表記を直す
50
50
  dict_str = dict_str.replace("false","False")