-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwebscrapping.java
More file actions
36 lines (33 loc) · 944 Bytes
/
webscrapping.java
File metadata and controls
36 lines (33 loc) · 944 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import java.io.IOException;
import java.net.URLEncoder;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
public class webscrapping {
public static void main(String args[]) throws IOException
{
org.jsoup.nodes.Document doc = null;
String s="space";
try
{
doc = Jsoup.connect("https://google.com/search?q=" +URLEncoder.encode(s ,"UTF-8") ).get();
System.out.println("[+] "+doc.title());
System.out.println("=======================================================================");
Elements links = doc.select("cite");
for(Element link : links)
{
if(link.text().contains("..."))
continue;
else
{
String str = link.text().replaceAll(" › ", "/");
System.out.println(str);
}
}
}
finally
{
System.out.println("===========================================================================");
}
}
}