Skip to content

Instantly share code, notes, and snippets.

@17
Created March 17, 2016 09:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 17/665500ee59465ba06f8e to your computer and use it in GitHub Desktop.
Save 17/665500ee59465ba06f8e to your computer and use it in GitHub Desktop.
def get_video_data(tweet_id, **kwargs):
video_page_url = 'https://twitter.com/i/videos/tweet/%s' % tweet_id
# player_id 播放次数 随机即可
params = {'embed_source': 'clientlib', 'player_id': 2, 'rpc_init': 1 }
vdieo_page_response = requests.get(video_page_url, params=params, verify=False, **kwargs)
if vdieo_page_response.status_code != requests.codes.ok:
return None
vdieo_page_soup = BeautifulSoup(vdieo_page_response.content, config.BEAUTIFULSOUP_PARSER)
vdieo_data_soup = vdieo_page_soup.find(id='playerContainer')
return json.loads(vdieo_data_soup.get('data-config'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment