Пример #1
0
def get_related_data_to_question(ques_url):
    html = urlopen(QUESTIONS_BASE_URL + ques_url)
    soup = BeautifulSoup(html, "lxml")

    question_summary = soup.find("a", "question-hyperlink").text
    question_desc = soup.find("div", "post-text").text

    user_details = soup.find("div", "user-details")
    user = user_details.find('a').text
    profile_url = user_details.find('a')['href']
    profile_url += BASE_URL
    rating = user_details.find('span').text
    tags = soup.find_all("a", "post-taglist")
    tags = tags[0].text.split(' ')
    category = ""
    answer = soup.find("div", "answer").text
    #user = soup.find("a", id="ct100_ct100_MC_AMC_QuestionAuthorRepInfo_MemberName")
    insert_data(question_id=question_desc,
                user=user,
                rating=rating,
                tags=tags,
                profile_url=profile_url,
                source_website=BASE_URL,
                answer=re.escape(answer),
                correct_answer=re.escape(answer),
                category=category)
Пример #2
0
def get_related_data_to_question(ques_url):
    html = urlopen(QUESTIONS_BASE_URL + ques_url)
    soup = BeautifulSoup(html, "lxml")
    question_summary = soup.find("a", "question-hyperlink").text
    question_desc = soup.find("div", "post-text").text

    user_details = soup.find("div", "user-details")
    user = user_details.find('a').text
    profile_url = user_details.find('a')['href']
    profile_url = QUESTIONS_BASE_URL + profile_url
    rating = user_details.find('span').text
    tags = soup.find_all("div", "post-taglist")
    tags = str(tags[0].text.split(' '))
    category = ""
    answer = soup.find("div", "answer").text
    import pdb
    pdb.set_trace()
    insert_data(question_id=question_desc,
                user=user,
                rating=rating,
                tags=tags,
                profile_url=profile_url,
                source_website=BASE_URL,
                answer=re.escape(answer),
                correct_answer=re.escape(answer),
                category=category)
Пример #3
0
def get_related_data_to_question(ques_url):
	html = urlopen(QUESTIONS_BASE_URL + ques_url)
	soup = BeautifulSoup(html, "lxml")
	question_desc = soup.find("div", "header").text
	user = soup.find("div", "member-rep-container").a.text
	profile_url = soup.find("div", "member-rep-container").a["href"]
	profile_url += BASE_URL
	rating = soup.find("div", "member-rep-container").span.text
	tags = get_all_tags(soup)
	category = ""
	answer = soup.find("div", "answer-row answer first").find("div", "text").text
	#user = soup.find("a", id="ct100_ct100_MC_AMC_QuestionAuthorRepInfo_MemberName")
	insert_data(question_short=question_desc, user=user, rating=rating, tags=tags, profile_url=profile_url, source_website=BASE_URL, answer=re.escape(answer), correct_answer=re.escape(answer), category=category)
Пример #4
0
def get_related_data_to_question(ques_url):
	html = urlopen(QUESTIONS_BASE_URL + ques_url)
	soup = BeautifulSoup(html, "lxml")
	question_summary = soup.find("a", "question-hyperlink").text
	question_desc = soup.find("div", "post-text").text

	user_details = soup.find("div", "user-details")
	user = user_details.find('a').text
	profile_url = user_details.find('a')['href']
	profile_url = QUESTIONS_BASE_URL + profile_url
	rating = user_details.find('span').text
	tags =  soup.find_all("div", "post-taglist")
	tags = str(tags[0].text.split(' '))
	category = ""
	answer = soup.find("div", "answer").text
	insert_data(question_short=question_desc, user=user, rating=rating, tags=tags, profile_url=profile_url, source_website=BASE_URL, answer=re.escape(answer), correct_answer=re.escape(answer), category=category)
Пример #5
0
def get_related_data_to_question(ques_url):
    html = urlopen(QUESTIONS_BASE_URL + ques_url)
    soup = BeautifulSoup(html, "lxml")
    question_desc = soup.find("div", "header").text
    user = soup.find("div", "member-rep-container").a.text
    profile_url = soup.find("div", "member-rep-container").a["href"]
    profile_url += BASE_URL
    rating = soup.find("div", "member-rep-container").span.text
    tags = get_all_tags(soup)
    category = ""
    answer = soup.find("div", "answer-row answer first").find("div",
                                                              "text").text
    #user = soup.find("a", id="ct100_ct100_MC_AMC_QuestionAuthorRepInfo_MemberName")
    insert_data(question_id=question_desc,
                user=user,
                rating=rating,
                tags=tags,
                profile_url=profile_url,
                source_website=BASE_URL,
                answer=re.escape(answer),
                correct_answer=re.escape(answer),
                category=category)