Quora CQA Problem Crawl _quora

Source: Internet
Author: User


Quora is a more well-known community question and answer site, for the current more popular CQA problem, through the Quora provided by the search tools to find similar problems and then extract answers.

In fact, Quora's search is roughly based on keyword matching.


String s=httprequest.sendget ("Https://www.quora.com/search", "q=have%20you%20ever%20done%20the%20nofap% 20Challenge? ");
Document doc = Jsoup.parse (s);
list<string> Answer_url = new arraylist<string> ();
Elements Ctag = Doc.select ("Div.pagedlist_item");
System.out.println (s);
for (element Question:ctag) {
	element href = question.select ("A.question_link").
	if (href!= null) {
		System.out.println ("www.quora.com" + href.attr ("href"));
		Answer_url.add ("https://www.quora.com" + href.attr ("href"));
	}
for (String url:answer_url) {
	//url = "http://www.quora.com/ What-is-the-craziest-thing-you-have-ever-said-or-done-at-an-interview-and-still-got-the-job ";
	String page = httprequest.sendget (URL, "");
	SYSTEM.OUT.PRINTLN (page);
	Solveanswerpage sol = new Solveanswerpage ();
	list<string> iRes = sol.solve (page);
	
	for (String tem:ires) {
	//	System.out.println (TEM);
	}
	//break;
}
System.out.println ("Done");


public class Solveanswerpage {public
	list<string> solve (String s) {
		list<string> res = new ArrayList <String> ();
		Document doc = Jsoup.parse (s);
		Elements answers = Doc.select ("Div.pagedlist_item");
		System.out.println (Answers.size ());
		for (Element answer:answers) {
			
			res.add (Answer.text ());
			
			System.out.println (Answer.text ());
		}
		return res;
	}


The main thing is to use the HttpRequest class to achieve the similar problem of a given problem crawl, mainly divided into two steps:

1. First of all, through the problem of a similar problem to search the page, get the list of the top questions URL link

2. According to the first step of the URL list, grab the corresponding problem page answer, and return to crawl results


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.