mirror of
https://gitlab.com/jeancf/twoot.git
synced 2025-01-18 15:27:07 +00:00
NOT WORKING: trying to get uncensored pic redirects to no_js page
This commit is contained in:
parent
3cb60ad963
commit
fd9130c053
41
twoot.py
41
twoot.py
|
@ -224,9 +224,9 @@ def main(argv):
|
|||
'The twitter page did not download correctly. Aborting'
|
||||
|
||||
# DEBUG: Save page to file
|
||||
#of = open('full_status_page.html', 'w')
|
||||
#of.write(full_status_page.text)
|
||||
#of.close()
|
||||
# of = open('full_status_page.html', 'w')
|
||||
# of.write(full_status_page.text)
|
||||
# of.close()
|
||||
|
||||
# Make soup
|
||||
soup = BeautifulSoup(full_status_page.text, 'html.parser')
|
||||
|
@ -236,6 +236,41 @@ def main(argv):
|
|||
assert contains_class(body_classes, 'tweets-show-page'), \
|
||||
'This is not the correct twitter page. Quitting'
|
||||
|
||||
# Check if tweet contains pic censored as "offensive media"
|
||||
if soup.find('div', class_='accept-data') is not None:
|
||||
print('Censored pic found')
|
||||
|
||||
# TODO if it does, submit form to obtain uncensored tweet
|
||||
# Submit POST form response with cookies
|
||||
headers.update(
|
||||
{
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Referer': full_status_url + '?p=v',
|
||||
}
|
||||
)
|
||||
|
||||
# Data payload for POST request
|
||||
authenticity_token = soup.find('input', {'name': 'authenticity_token'}).get('value')
|
||||
form_input = {'show_media': 1, 'authenticity_token': authenticity_token, 'commit': 'Display media'}
|
||||
|
||||
print(full_status_url)
|
||||
print(headers)
|
||||
print(form_input)
|
||||
print(full_status_page.cookies)
|
||||
|
||||
full_status_page = requests.post(full_status_url + '?p=v', data=form_input, headers=headers, cookies=full_status_page.cookies)
|
||||
|
||||
# Verify that download worked
|
||||
assert twit_account_page.status_code == 200, \
|
||||
'The twitter page did not download correctly. Aborting'
|
||||
|
||||
# DEBUG: Save page to file
|
||||
of = open('full_status_page.html', 'w')
|
||||
of.write(full_status_page.text)
|
||||
of.close()
|
||||
|
||||
sys.exit(-1)
|
||||
|
||||
# Isolate table main-tweet
|
||||
tmt = soup.find('table', class_='main-tweet')
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user