Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
shadowban-eu-backend
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
shadowban-eu-backend
Commits
069a9b56
Commit
069a9b56
authored
Jul 03, 2023
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new thing
parent
de16a5e8
Pipeline
#22556
canceled with stages
in 29 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
83 additions
and
50 deletions
+83
-50
backend_requests.py
backend_requests.py
+83
-50
No files found.
backend_requests.py
View file @
069a9b56
...
@@ -81,49 +81,47 @@ def getTwitterSession(useCookie):
...
@@ -81,49 +81,47 @@ def getTwitterSession(useCookie):
def
doSearch
(
screen_name
):
def
doSearch
(
screen_name
):
global
isHealthy
global
isHealthy
twitter_b
=
getTwitterSession
(
True
)
twitter_b
=
getTwitterSession
(
True
)
searchurl_v2
=
"https://
api.twitter.com/2/search/adaptive.json
"
searchurl_v2
=
"https://
twitter.com/i/api/graphql/nK1dw4oV3k4w5TdtcAdSww/SearchTimeline
"
params_v2
=
{
params_v2
=
{
"q"
:
"from:@{}"
.
format
(
screen_name
),
"features"
:
json
.
dumps
({
"count"
:
1
,
"rweb_lists_timeline_redesign_enabled"
:
True
,
# "spelling_corrections": 0,
"responsive_web_graphql_exclude_directive_enabled"
:
True
,
"tweet_search_mode"
:
"live"
,
"verified_phone_label_enabled"
:
False
,
"include_profile_interstitial_type"
:
1
,
"creator_subscriptions_tweet_preview_api_enabled"
:
True
,
"include_blocked_by"
:
1
,
"responsive_web_graphql_timeline_navigation_enabled"
:
True
,
"include_blocking"
:
1
,
"responsive_web_graphql_skip_user_profile_image_extensions_enabled"
:
False
,
"include_followed_by"
:
1
,
"tweetypie_unmention_optimization_enabled"
:
True
,
"include_want_retweets"
:
1
,
"responsive_web_edit_tweet_api_enabled"
:
True
,
"include_mute_edge"
:
1
,
"graphql_is_translatable_rweb_tweet_is_translatable_enabled"
:
True
,
"include_can_dm"
:
1
,
"view_counts_everywhere_api_enabled"
:
True
,
"include_can_media_tag"
:
1
,
"longform_notetweets_consumption_enabled"
:
True
,
"skip_status"
:
1
,
"responsive_web_twitter_article_tweet_consumption_enabled"
:
False
,
"cards_platform"
:
"Web-12"
,
"tweet_awards_web_tipping_enabled"
:
False
,
"include_cards"
:
1
,
"freedom_of_speech_not_reach_fetch_enabled"
:
True
,
"include_ext_alt_text"
:
'true'
,
"standardized_nudges_misinfo"
:
True
,
"include_quote_count"
:
'true'
,
"tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled"
:
True
,
"include_ext_limited_action_results"
:
'false'
,
"longform_notetweets_rich_text_read_enabled"
:
True
,
"include_reply_count"
:
1
,
"longform_notetweets_inline_media_enabled"
:
True
,
"tweet_mode"
:
"extended"
,
"responsive_web_media_download_video_enabled"
:
False
,
"include_ext_collab_control"
:
'false'
,
"responsive_web_enhance_cards_enabled"
:
False
"include_ext_views"
:
'true'
,
}),
"include_entities"
:
'true'
,
"variables"
:
json
.
dumps
({
"include_user_entities"
:
'true'
,
"count"
:
20
,
"include_ext_media_color"
:
'true'
,
"querySource"
:
"typed_query"
,
"include_ext_media_availability"
:
'true'
,
"product"
:
"Top"
,
"include_ext_sensitive_media_warning"
:
'true'
,
"rawQuery"
:
"from:@"
+
screen_name
,
"include_ext_trusted_friends_metadata"
:
'true'
,
}),
"send_error_codes"
:
'true'
,
"fieldToggles"
:
json
.
dumps
({
"simple_quoted_tweet"
:
'true'
,
"withArticleRichContentState"
:
False
"query_source"
:
"recent_search_click"
,
})
"pc"
:
1
,
"spelling_corrections"
:
1
,
"include_ext_edit_control"
:
'true'
,
"ext"
:
'mediaStats,highlightedLabel,hasNftAvatar,voiceInfo,birdwatchPivot,enrichments,superFollowMetadata,unmentionInfo,editControl,collab_control,vibe'
,
}
}
response
=
twitter_b
.
get
(
searchurl_v2
,
params
=
params_v2
)
response
=
twitter_b
.
get
(
searchurl_v2
,
params
=
params_v2
)
print
(
"Search: "
+
response
.
text
)
search_v2
=
response
.
json
()
search_v2
=
response
.
json
()
isHealthy
=
'
globalObjects
'
in
search_v2
isHealthy
=
'
data
'
in
search_v2
if
isHealthy
:
if
isHealthy
:
return
search_v2
[
"
globalObjects"
][
"tweet
s"
]
return
search_v2
[
"
data"
][
"search_by_raw_query"
][
"search_timeline"
][
"timeline"
][
"instruction
s"
]
else
:
else
:
print
(
"Search error: "
+
response
.
text
)
print
(
"Search error: "
+
response
.
text
)
return
None
return
None
...
@@ -211,8 +209,25 @@ def searchban(screen_name):
...
@@ -211,8 +209,25 @@ def searchban(screen_name):
# returnjson["profile"]["has_tweets"] = True
# returnjson["profile"]["has_tweets"] = True
# check whether the user has any tweets
# check whether the user has any tweets
usertlurl
=
"https://api.twitter.com/1.1/statuses/user_timeline.json"
#usertlurl = "https://api.twitter.com/1.1/statuses/user_timeline.json"
params
=
{
"screen_name"
:
screen_name
,
"count"
:
200
}
#params = {"screen_name": screen_name, "count": 200}
usertlurl
=
'https://twitter.com/i/api/graphql/oUZZZ8Oddwxs8Cd3iW3UEA/UserByScreenName'
params
=
{
'variables'
:
json
.
dumps
({
'screen_name'
:
screen_name
,
'withSafetyModeUserFields'
:
True
,
}),
'features'
:
json
.
dumps
({
"hidden_profile_likes_enabled"
:
False
,
"responsive_web_graphql_exclude_directive_enabled"
:
True
,
"verified_phone_label_enabled"
:
False
,
"subscriptions_verification_info_verified_since_enabled"
:
True
,
"highlights_tweets_tab_ui_enabled"
:
True
,
"creator_subscriptions_tweet_preview_api_enabled"
:
True
,
"responsive_web_graphql_skip_user_profile_image_extensions_enabled"
:
False
,
"responsive_web_graphql_timeline_navigation_enabled"
:
True
})
}
usertl_b
=
twitter_b
.
get
(
usertlurl
,
params
=
params
)
usertl_b
=
twitter_b
.
get
(
usertlurl
,
params
=
params
)
usertl
=
usertl_b
usertl
=
usertl_b
...
@@ -231,8 +246,8 @@ def searchban(screen_name):
...
@@ -231,8 +246,8 @@ def searchban(screen_name):
if
usertl
.
status_code
==
200
:
if
usertl
.
status_code
==
200
:
returnjson
[
"profile"
][
"exists"
]
=
True
returnjson
[
"profile"
][
"exists"
]
=
True
returnjson
[
"profile"
][
"id"
]
=
usertl_json
[
0
][
"user"
][
"id_str
"
]
returnjson
[
"profile"
][
"id"
]
=
usertl_json
[
'data'
][
"user"
][
"result"
][
"rest_id
"
]
returnjson
[
"profile"
][
"screen_name"
]
=
usertl_json
[
0
][
"user
"
][
"screen_name"
]
returnjson
[
"profile"
][
"screen_name"
]
=
usertl_json
[
'data'
][
"user"
][
"result"
][
"legacy
"
][
"screen_name"
]
# returnjson["profile"]["protected"] = usertl_json["protected"]
# returnjson["profile"]["protected"] = usertl_json["protected"]
elif
usertl
.
status_code
==
403
:
elif
usertl
.
status_code
==
403
:
returnjson
[
"profile"
][
"suspended"
]
=
True
returnjson
[
"profile"
][
"suspended"
]
=
True
...
@@ -284,17 +299,35 @@ def searchban(screen_name):
...
@@ -284,17 +299,35 @@ def searchban(screen_name):
if
returnjson
[
"tests"
][
"typeahead"
]
==
False
:
if
returnjson
[
"tests"
][
"typeahead"
]
==
False
:
print
(
"{} is search suggestion banned, checking search ban."
.
format
(
screen_name
))
print
(
"{} is search suggestion banned, checking search ban."
.
format
(
screen_name
))
search_
tweets
=
doSearch
(
screen_name
)
search_
result
=
doSearch
(
screen_name
)
if
search_
tweets
is
None
:
if
search_
result
is
None
:
returnjson
[
"tests"
][
"search"
]
=
'_error'
returnjson
[
"tests"
][
"search"
]
=
'_error'
hasFailure
=
True
hasFailure
=
True
elif
search_tweets
==
{}:
returnjson
[
"tests"
][
"search"
]
=
False
print
(
"{} is search banned."
.
format
(
screen_name
))
# returnjson["tests"]["typeahead"] = False
else
:
else
:
returnjson
[
"tests"
][
"search"
]
=
str
(
search_tweets
[
list
(
search_tweets
.
keys
())[
0
]][
"id"
])
found_id
=
None
print
(
"{} is not search banned."
.
format
(
screen_name
))
for
item
in
search_result
:
if
item
[
'type'
]
!=
'TimelineAddEntries'
:
continue
for
entry_item
in
item
[
'entries'
]:
if
not
entry_item
[
'entryId'
]
.
startswith
(
'tweet-'
):
continue
found_id
=
entry_item
[
'content'
][
'itemContent'
][
'tweet_results'
][
'result'
][
'rest_id'
]
break
if
found_id
:
break
if
found_id
:
returnjson
[
"tests"
][
"search"
]
=
found_id
print
(
"{} is not search banned: {}"
.
format
(
screen_name
,
found_id
))
else
:
returnjson
[
"tests"
][
"search"
]
=
False
print
(
"{} is search banned."
.
format
(
screen_name
))
#elif search_tweets == {}:
# returnjson["tests"]["search"] = False
# print("{} is search banned.".format(screen_name))
# # returnjson["tests"]["typeahead"] = False
#else:
# returnjson["tests"]["search"] = str(search_tweets[list(search_tweets.keys())[0]]["id"])
# print("{} is not search banned.".format(screen_name))
else
:
else
:
returnjson
[
"tests"
][
"search"
]
=
"_implied_good"
returnjson
[
"tests"
][
"search"
]
=
"_implied_good"
print
(
"{} is not search suggestion banned, skipped search ban check."
.
format
(
screen_name
))
print
(
"{} is not search suggestion banned, skipped search ban check."
.
format
(
screen_name
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment