这是代码
from bs4 import BeautifulSoup
import requests
r = requests.get('https://www.betexplorer.com/tennis/wta-singles/dubai/siniakova-katerina-kvitova-petra/6ZCipZ9h/')
soup = BeautifulSoup(r.text,'html.parser')
Odds = soup.find_all('td', attrs= {'class':'table-main__detail-odds table-main__detail-odds--first'})
print(odds)
[]
这是错误
public void openCamera() {
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File file = new File(Environment.getExternalStorageDirectory(), "image.jpg");
imageURI = Uri.fromFile(file);
intent.putExtra(MediaStore.EXTRA_OUTPUT, imageURI);
startActivityForResult(intent, CAMERA);
}
尝试了文件提供程序,但是我不确定如何实现它。使代码无法运行。抱歉...我很烂
答案 0 :(得分:1)
使用此代码获取android N或以上版本的uri:
private Uri getFileUri(Context context, Uri fileUri, File file) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
return FileProvider.getUriForFile(context, context.getPackageName() + ".provider", file);
} else {
return fileUri;
}
}
不要忘记添加带有意图的标志:
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
答案 1 :(得分:0)
如果targetSdkVersion> = 24,则无法在Android 7.0+设备上的Intents中使用file:Uri值。您可以这样更改代码:
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
ContentValues contentValues = new ContentValues(1);
contentValues.put(MediaStore.Images.Media.DATA, file.getAbsolutePath());
Uri uri = getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, contentValues);
intent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
startActivityForResult(intent, CAMERA);
有关更多详细信息:Android camera intent FileUriExposedException for SDK >= 24和 https://developer.android.com/training/secure-file-sharing/setup-sharing