Click here to Skip to main content
15,890,557 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,
I need to write a java code which interacts with glassdoor[^] and checks out average rating of my company. I did following things
--> created an employee account
-->Requested for a token key
But glassdoor is not seeming to have an api to give me statistics of my company. Is there a way wherein i can get the stats of my comapny(like number of reviews posted for my company, average rating )
Posted
Comments
Shubhashish_Mandal 13-Dec-13 2:50am    
I think in that case you should crawl(need permission) the site to fetch the required information.
Richard MacCutchan 13-Dec-13 3:39am    
If they do not provide an API or XML feed, then you have no choice but to use screen scraping. Search Google on the subject and you will probably find some good samples.
coolRahul_12 13-Dec-13 4:54am    
Thanks for the reply Richard. I think this technique is a better one

1 solution

got the solution myself
Java
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;


public class glass {
	public static void main(String []args) throws IOException{
		ArrayList<string>good=new ArrayList<string>();
		ArrayList<string>bad=new ArrayList<string>();
		String a="//Glassdoor url of the company";
		URL url=new URL(a);
		URLConnection conn=url.openConnection();
		BufferedReader br=new BufferedReader(newInputStreamReader(conn.getInputStream()));
		String i;
		String filename="D:/comment.txt";
		String gfile="D:/pros.txt";
		String bfile="D:/cons.txt";
		File file=new File(filename);
		File pro=new File(gfile);
		File con=new File(bfile);
		if(!file.exists()){
			file.createNewFile();
		}
		if(!pro.exists()){
			pro.createNewFile();
		}
		if(!con.exists()){
			con.createNewFile();
		}
		FileWriter fw=new FileWriter(file);
		BufferedWriter bw=new BufferedWriter(fw);
		FileWriter fpros=new FileWriter(pro);
		BufferedWriter bpros=new BufferedWriter(fpros);
		FileWriter fcons=new FileWriter(con);
		BufferedWriter bcon=new BufferedWriter(fcons);
		while((i=br.readLine())!=null){
			bw.write(br.readLine());
		}
		br.close();
		bw.close();
		FileReader fr=new FileReader(file);
		StringBuffer sb=new StringBuffer();
		BufferedReader br1=new BufferedReader(fr);
		String input=null;
		while((input=br1.readLine())!=null){
			sb.append(input);
		}
		input=sb.toString();
		String pros="(.*?)<br />";
		String cons="(.*?)<br />";
		Pattern pattern=Pattern.compile(pros);
		Pattern p1=Pattern.compile(cons);
		Matcher m1=pattern.matcher(input);
		Matcher m2=p1.matcher(input);
		while(m1.find()){
			System.out.println(m1.group(2));
			//good.add(m1.group(2));
			
		}
		/*while(m2.find()){
			bad.add(m2.group(2));
		}*/
		System.out.println(good.size());
		/*for(int j=0;j<good.size();j++){>
			
			bpros.write("{");
			bpros.write(good.get(j));
			bpros.write("}");
		}*/
		/*for(int j=0;j<bad.size();j++){>
			bcon.write("{");
			bcon.write(bad.get(j));
			bcon.write("}");
		}
		*/
		System.out.println("completed");
	}

}</string></string></string></string>
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900