Find all the links in a web page

Discussion in 'Plugin Development' started by jtjj222, Sep 1, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    jtjj222

    I was wondering how I would go about finding all the links in a web page. All I have is this, but it doesn't work:
    Code:
    Document doc = Jsoup.connect(Url).get();
    Elements tdFiles = doc.select("a[href]");
    for (Element e: tdFiles) {
    String link = e.text();
    System.out.println(link);
    }
    
    Can anyone help on this? The Jsoup documentation is a little confusing, does anyone have any other library that might work well for my situation?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 28, 2016
  2. Offline

    gjossep

    I know a other library, Let me just try to find it!

    :)
     
  3. Offline

    Njol

    What do you need all links for?
     
  4. Offline

    gjossep

    First you can get the source of a webpage. I presume you know how to do that. Then You can use the StringUtils.substringBetween(). That should work...

    Hope thats clear. Any questions then tag me in the post.
     
  5. Offline

    jtjj222

    Getting the source then searching through it for links seems a little tedious. I am making a remote plugin installer. So far, I can download and install .jar files from a link. Now, I am trying to search through bukkitdev web pages to find the download links for plugins. I tried to search for all a tags, but I keep getting this error, which I think is caused by eclipse not compiling my plugin properly:
    Code:
    at org.bukkit.command.PluginCommand.execute(PluginCommand.java:42)
    at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:168)
    at org.bukkit.craftbukkit.CraftServer.dispatchCommand(CraftServer.java:492)
    at org.bukkit.craftbukkit.CraftServer.dispatchServerCommand(CraftServer.java:488)
    at net.minecraft.server.DedicatedServer.ah(DedicatedServer.java:248)
    at net.minecraft.server.DedicatedServer.q(DedicatedServer.java:213)
    at net.minecraft.server.MinecraftServer.p(MinecraftServer.java:474)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:406)
    at net.minecraft.server.ThreadServerApplication.run(SourceFile:539)
    Caused by: java.lang.NoClassDefFoundError: org/jsoup/Jsoup
    at me.jtjj222.BukkitRepo.BukkitRepo.onCommand(BukkitRepo.java:34)
    at org.bukkit.command.PluginCommand.execute(PluginCommand.java:40)
    ... 8 more
    Caused by: java.lang.ClassNotFoundException: org.jsoup.Jsoup
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:44)
    at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:29)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 10 more
     
    
     
  6. Offline

    gjossep

    I have already made that plugin... And thats how i did it...
    Link to plugin:
    http://dev.bukkit.org/server-mods/dwlplugin/
     
  7. Offline

    jtjj222

    You have? :-{
    I searched everywhere to find one and couldn't. Well, guess my question is answered :D
     
  8. Offline

    gjossep

    No prob. Tell me where i can improve on the plugin
     
  9. Offline

    Njol

    There are also at least two auto updaters in the ressources forum ;)
     
Thread Status:
Not open for further replies.

Share This Page