Created
September 12, 2018 20:53
-
-
Save CihatAltiparmak/934eba56cbcf7ed0e4ec7c741bce558c to your computer and use it in GitHub Desktop.
This file contains 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 characters
from flask import Flask | |
from robobrowser import RoboBrowser | |
from bs4 import BeautifulSoup | |
import json | |
app = Flask(__name__) | |
@app.route('/') | |
def anasayfa(): | |
return "anasayfa" | |
@app.route('/anlam_ogren/') | |
def ogren(): | |
return "gösterilebilir bir şey yok" | |
@app.route('/anlam_ogren/<string:name>/') | |
def anlam(name): | |
br = RoboBrowser(parser = "html.parser") | |
br.open("http://www.tdk.gov.tr/index.php?option=com_gts&arama") | |
form = br.get_form() | |
form["kelime"] = name | |
br.submit_form(form)#pass #This part will be with robobrowser. | |
page = br.parsed | |
soup = BeautifulSoup(str(page), "html.parser") | |
result = "" | |
for i in soup.find_all("table",{"id":"hor-minimalist-a"}): | |
result += i.find("td").text | |
data = {name : result} | |
data = json.dumps(data) | |
return data | |
if __name__ == "__main__": | |
app.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment