コード例 #1
0
    @Override
    protected String doInBackground(String... urls) {
      Document doc = null;

      try {
        Connection.Response res =
            Jsoup.connect(urls[0])
                .data("eid", mUserName)
                .timeout(3000)
                .data("pw", mPassword)
                .data("submit", "Login")
                .method(Method.POST)
                .execute();

        doc = res.parse();

        // get the cookie
        mCookieValue = res.cookie(COOKIE_TYPE);
        mLoginResponse = doc.toString();
        /*				Log.w("response", doc.toString());*/

      } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
      return mLoginResponse;
    }
コード例 #2
0
ファイル: PagesNumber.java プロジェクト: knockout1/CarPrices
  protected Integer doInBackground(String... params) {
    String url = params[0];
    int i = 0;
    try {
      Connection.Response res = Jsoup.connect(url).userAgent("Mozilla").execute();
      Document doc = res.parse();
      Elements pages = doc.getElementsByClass("last");
      i = Integer.parseInt(pages.get(1).childNode(0).toString());
    } catch (Exception e) {

    }
    return i;
  }
コード例 #3
0
 @Override
 public OvercastPlayer getPlayerByUrl(URL url) {
   try {
     Connection.Response response =
         Jsoup.connect(url.toString())
             .method(Connection.Method.GET)
             .userAgent(userAgent)
             .timeout(connectionTimeout)
             .execute();
     return new ParsedPlayer(this, response.parse());
   } catch (IOException e) {
     e.printStackTrace();
   }
   return null;
 }
コード例 #4
0
 @Override
 public OvercastPlayer getPlayerByName(String username) {
   String url = "https://oc.tc/users/" + username;
   try {
     Connection.Response response =
         Jsoup.connect(url)
             .method(Connection.Method.GET)
             .userAgent(userAgent)
             .timeout(connectionTimeout)
             .execute();
     return new ParsedPlayer(this, response.parse());
   } catch (IOException e) {
     e.printStackTrace();
   }
   return null;
 }
コード例 #5
0
 @Override
 public List<OvercastPlayer> getPlayersByUrl(List<URL> urls) {
   List<OvercastPlayer> playerList = new ArrayList<OvercastPlayer>();
   for (URL url : urls) {
     try {
       Connection.Response response =
           Jsoup.connect(url.toString())
               .method(Connection.Method.GET)
               .userAgent(userAgent)
               .timeout(connectionTimeout)
               .execute();
       playerList.add(new ParsedPlayer(this, response.parse()));
     } catch (IOException e) {
       e.printStackTrace();
     }
   }
   return playerList;
 }
コード例 #6
0
  @Override
  public List<OvercastPlayer> getPlayersByUuid(List<UUID> uuids) {
    List<OvercastPlayer> playerList = new ArrayList<OvercastPlayer>();
    for (UUID uuid : uuids) {
      String url = "https://oc.tc/users/" + MojangUtil.getUsername(String.valueOf(uuid));
      try {
        Connection.Response response =
            Jsoup.connect(url)
                .method(Connection.Method.GET)
                .userAgent(userAgent)
                .timeout(connectionTimeout)
                .execute();
        playerList.add(new ParsedPlayer(this, response.parse()));

      } catch (IOException e) {
        e.printStackTrace();
      }
    }
    return playerList;
  }
コード例 #7
0
  @Override
  public List<OvercastPlayer> getPlayersByName(List<String> usernames) {
    List<OvercastPlayer> playerList = new ArrayList<OvercastPlayer>();
    for (String username : usernames) {
      String url = "https://oc.tc/users/" + username;
      try {
        Connection.Response response =
            Jsoup.connect(url)
                .method(Connection.Method.GET)
                .userAgent(userAgent)
                .timeout(connectionTimeout)
                .execute();
        playerList.add(new ParsedPlayer(this, response.parse()));

      } catch (IOException e) {
        e.printStackTrace();
      }
    }
    return playerList;
  }
コード例 #8
0
ファイル: main_window.java プロジェクト: ArtemovSA/Parser_go
  private void jButton1ActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButton1ActionPerformed

    Connection.Response res = null;
    String url_country;
    String prefix;

    try {
      url_search = url_search + jTextField_search.getText() + "\"";
      res = Jsoup.connect(url_search).method(Method.GET).timeout(20000).execute();

      doc = res.parse();

      switch (jComboBox_country.getSelectedIndex()) {
        case 0:
          url_country =
              "http://ru.kompass.com/en/searchCompanies/facet?value=RU&label=%20Russian%20Federation&filterType=countrynational&searchType=ALL&checked=true";
          prefix = "/ru";
          break;
        case 1:
          url_country =
              "http://ru.kompass.com/en/searchCompanies/facet?value=BR&label=Brazil&filterType=country&searchType=ALL&checked=true";
          prefix = "/br";
          break;
        case 2:
          url_country =
              "http://ru.kompass.com/en/searchCompanies/facet?value=CN&label=China&filterType=country&searchType=ALL&checked=true";
          prefix = "/cn";
          break;
        case 3:
          url_country =
              "http://ru.kompass.com/en/searchCompanies/facet?value=ZA&label=South%20Africa&filterType=country&searchType=ALL&checked=true";
          prefix = "/za";
          break;
        case 4:
          url_country =
              "http://ru.kompass.com/en/searchCompanies/facet?value=IN&label=India&filterType=country&searchType=ALL&checked=true";
          prefix = "/in";
          break;
        default:
          url_country =
              "http://ru.kompass.com/en/searchCompanies/facet?value=RU&label=%20Russian%20Federation&filterType=countrynational&searchType=ALL&checked=true";
          prefix = "/ru";
      }

      doc =
          Jsoup.connect(url_country)
              .cookies(res.cookies())
              .userAgent(
                  "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.154 Safari/537.36")
              .timeout(20000)
              .get();

      Elements sheet = doc.select("#paginatorDivId > li > a");
      for (int i = 0; i < sheet.size(); i++) {
        sheet_urls[i] = "http://ru.kompass.com" + sheet.get(i).attr("href");
        jTextArea_sheets.append(sheet_urls[i] + "\n");
      }

      jTextArea_company.setText("");
      count_urls = 0;
      int count_sheets = sheet.size();
      jLabel_sheets.setText(Integer.toString(count_sheets));

      for (int s = 0; s < count_sheets; s++) {

        doc =
            Jsoup.connect(sheet_urls[s])
                .cookies(res.cookies())
                .userAgent(
                    "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.154 Safari/537.36")
                .timeout(20000)
                .get();

        Elements links = doc.select("div.details > h2 > a[href]");

        for (int i = 0; i < links.size(); i++) {
          String buf_str = links.get(i).attr("href");
          urls[count_urls] =
              "http://ru.kompass.com" + buf_str.substring(buf_str.indexOf(prefix, 0));
          jTextArea_company.append(urls[count_urls] + "\n");
          count_urls++;
        }

        jLabel_name.setText(doc.title());
        jLabel1.setText(String.valueOf(count_urls));
      }

    } catch (IOException ex) {
      Logger.getLogger(main_window.class.getName()).log(Level.SEVERE, null, ex);
    }
  } // GEN-LAST:event_jButton1ActionPerformed
コード例 #9
0
 public Document post() throws IOException {
   req.method(Method.POST);
   execute();
   return res.parse();
 }