我正在尝试使用jsoup登录网站,然后抓取信息,我遇到问题,我可以成功登录并从index.php创建一个文档,但我无法在网站上获取其他页面.我知道我需要在发布后设置一个cookie,然后在我尝试在网站上打开另一个页面时加载它.但是我该怎么做?以下代码允许我登录并获取index.php
Document doc = Jsoup.connect("http://www.example.com/login.php")
.data("username", "myUsername",
"password", "myPassword")
.post();
Run Code Online (Sandbox Code Playgroud)
我知道我可以使用apache httpclient来做到这一点,但我不想这样做.
我正在尝试在 webview 中向下滚动到页面底部,我正在使用他们教程中提供的 webview 示例 google。我正在使用这行代码尝试滚动,但它不起作用。mWebView.pageDown(true); 关于如何以编程方式滚动的任何建议?谢谢你。
public class WebViewExample extends Activity {
private static final String LOG_TAG = "WebViewDemo";
private WebView mWebView;
private Handler mHandler = new Handler();
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
mWebView = (WebView) findViewById(R.id.webview);
WebSettings webSettings = mWebView.getSettings();
webSettings.setSavePassword(false);
webSettings.setSaveFormData(false);
webSettings.setJavaScriptEnabled(true);
webSettings.setSupportZoom(false);
mWebView.setWebChromeClient(new MyWebChromeClient());
mWebView.addJavascriptInterface(new DemoJavaScriptInterface(), "demo");
mWebView.loadUrl("http://www.google.com/search?q=android+webview+scroll+doesnt+work&hl=en&safe=off&prmd=ivns&ei=0b0cTquNNI6WsgP6l7igBQ&start=10&sa=N#sclient=psy&hl=en&safe=off&source=hp&q=android%20webview%20scrollable&pbx=1&oq=&aq=&aqi=&aql=&gs_sm=&gs_upl=&bav=on.2,or.r_gc.r_pw.&fp=c306e119a7d85f91&biw=1280&bih=738&pf=p&pdl=300");
//this is where I try to scroll, doesn't work
mWebView.pageDown(true);
}
final class DemoJavaScriptInterface {
DemoJavaScriptInterface() {
}
/**
* This is not called on …
Run Code Online (Sandbox Code Playgroud) 我想使用JSoup将一些文本提交到此表单中.我该怎么做呢?
<form id="quickpostform" action="" method="post" style="display: block; text-align: center; ">
<input type="hidden" name="action" value="reply"/>
<input type="hidden" name="auth" value="54a9871a63a1c285879a5327faf3d8d2"/>
<input type="hidden" name="thread" value="135454"/>
<div id="quickreplytext">
<textarea id="quickpost" style="width: 95%; " tabindex="1" onkeyup="resize('quickpost');" name="body" cols="90" rows="8"/>
<br/>
</div>
Run Code Online (Sandbox Code Playgroud)