SHARE
TWEET

Untitled

a guest Nov 13th, 2018 80 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import requests
  2. from bs4 import BeautifulSoup
  3. import sys
  4.  
  5. def search_word_from_account_on_twitter(screen_name, words):
  6.     URL = "https://mobile.twitter.com/search?q=from%3A" + screen_name + "%20" + words
  7.     # print(URL) # デバッグ用 検索しているURLが確認できる
  8.     r = requests.get(URL)
  9.  
  10.     # print(r.status_code) # デバッグ用 #サーバーエラーかどうか確認するためのもの httpステータスコードを返す
  11.     soup = BeautifulSoup(r.content, "lxml")
  12.     # div = soup.find_all("div", class_="noresults")
  13.  
  14.     if soup.find_all("div", class_="noresults"):
  15.         # 検索して見つからなかったときの処理
  16.         result = False
  17.  
  18.     else:
  19.         # 検索して見つかったときの処理
  20.         result = True
  21.  
  22.     return result
  23.  
  24.  
  25. def main(screen_name, search_words):
  26.     result = search_word_from_account_on_twitter(screen_name, search_words)
  27.     print(result)
  28.  
  29.  
  30. if __name__ == "__main__":
  31.     screen_name_main = sys.argv[1]
  32.     search_word_main = sys.argv[2]
  33.    
  34.     main(screen_name_main, search_words_main)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top