Created
May 17, 2017 23:26
-
-
Save undefinedzain/c10716e1813d292690a6fafb661e66a5 to your computer and use it in GitHub Desktop.
Revisions
-
undefinedzain created this gist
May 17, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,32 @@ import requests from bs4 import BeautifulSoup import sys if len(sys.argv) == 1: print ('Please input at least a word, i.e python scraping.py bisa') else: kata = sys.argv[1] headers = {'User-Agent': 'Mozilla/5.0'} payload = {'q':kata} session = requests.Session() resp = session.post('http://www.persamaankata.com/search.php',headers=headers,data=payload) html_element = BeautifulSoup(resp.content,'lxml') if len(html_element.find_all('ul')) > 0: all_ul = html_element.find_all('ul')[0] # Sinonim aja ul[1] isinya antonim all_ul.find_all('div',{'class' : 'word_thesaurus'}) a = all_ul.find_all('a') synonim_array = [] for sinonim in a: print(sinonim).text else: print('Please input right words') This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,5 @@ # For usage just run command below python synonim_scraping.py baik OR python synonim_scraping.py tampan