【发布时间】:2019-07-22 07:36:43
【问题描述】:
我正在使用 Flutter http 包来获取网页。 我想发送像桌面这样的http请求。我该怎么做?
我的用户代理:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36"
我的代码;
String text="mert";
var isLoading = false;
_fetchData() async {
final response =
await http.get("http://trscript.net");
if (response.statusCode == 200) {
var document = parse(response.body.toString());
if(document.querySelector("body > div > div.sol.yaklas > div:nth-child(1) > article > div.yazi_bilgi")!=null){
text = document.querySelector("body > div > div.sol.yaklas > div:nth-child(1) > article > div.yazi_bilgi").text;
}
} else {
throw Exception('Failed to load photos');
}
}
【问题讨论】:
标签: http flutter dart httprequest