-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfetch_thread_username.java
More file actions
67 lines (57 loc) · 1.97 KB
/
Copy pathfetch_thread_username.java
File metadata and controls
67 lines (57 loc) · 1.97 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import java.util.*;
import java.net.*;
//Clipboard
import java.awt.datatransfer.StringSelection;
import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
//to find - href="/profile/
class fetch_thread_username
{
static String content = null;
public static void main(String []args)
{
Scanner sc = new Scanner(System.in);
URLConnection connection = null;
try
{
System.out.println("Enter Link:");
String link=sc.nextLine();
System.out.print("Fetching...");
connection = new URL(link).openConnection();
Scanner scanner = new Scanner(connection.getInputStream());
scanner.useDelimiter("\\Z");
content = scanner.next();
scanner.close();
}
catch(Exception ex)
{
ex.printStackTrace();
}
find();
}
static void find()
{
String userClip="";
while(content.length()!=0)
{
int pos=content.indexOf("href=\"/profile/");
if(pos==-1)
break;
int posS=content.indexOf("\"",pos+6);
String username=content.substring(pos+15,posS);
if(userClip.indexOf(username)==-1)
{
userClip=userClip+"@"+username+"\n";
}
content=content.substring(posS);
}
System.out.println("\b\b\b\b\b\b\b\b\b\b\bDone!! ");
System.out.println("");
System.out.println(userClip);
System.out.println("All the above usernames have been copied to clipboard.");
System.out.println("~made by neiinc (https://myanimelist.net/profile/neiinc)");
StringSelection stringSelection = new StringSelection(userClip);
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(stringSelection, null);
}
}