维基百科API没有为某些查询返回任何内容
Wikipedia API not returning anything for some queries
HTML
<html>
<head>
</head>
<form action="check2.php" method="POST">
Search <input type="text" name="search" />
<input type="submit" name="searchbtn" value="search" />
</form>
</body>
</html>
PHP
<?php
$string = $_POST['search'];
$convert = rawurlencode($string);
$url = 'http://en.wikipedia.org/w/api.php?action=query&prop=revisions&rvprop=content&format=xml&redirects&titles='.$convert;
if($_POST['search'] != '' || $_POST['search'] != null) {
$ch = curl_init($url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$c = curl_exec($ch);
echo $c;
} else {
}
?>
如果我搜索(例如)"New York",它会返回XML,但如果我搜索"Singapore Zoo",则不返回任何内容
首先,您应该设置一个用户代理。其次,这不是搜索,而是导出特定标题的页面;您正在寻找action=opensearch。
https://en.wikipedia.org/w/api.php?action=opensearch&search=api&limit=1&namespace=0&search=新加坡动物园&utf8=true给出:
["Singapore_Zoo",["Singapore Zoo"],["The Singapore Zoo (Chinese: 新加坡动物园; pinyin: Xīnjiāpō Dòngwùyuán; Malay: 'Taman Haiwan Singapura'; Tamil: சிங்கப்பூர் விலங்குக் காட்சிச்சாலை), formerly known as the Singapore Zoological Gardens and commonly known locally as the Mandai Zoo, occupies 28 hectares (69 acres) on the margins of Upper Seletar Reservoir within Singapore's heavily forested central catchment area."],["https://en.wikipedia.org/wiki/Singapore_Zoo"]]
相关文章:
- 使用DynamoDB查询返回
- Firebase:查询返回null
- sqlite查询返回错误-can'我不知道为什么
- 需要呈现MongoDB查询返回结果的特定索引/位置
- mongoose查询返回链接到用户的产品
- Node.js:从mongoose查询返回正确的JSON
- 当查询返回对象时,Express Mongo回调返回undefined
- 无法向 Mongoose 查询返回的对象添加新属性
- 将 mysql 查询返回的数据转换为 json(基于树)
- 获取所有表行并使用 CasperJS 中的 XPath 查询返回它们
- 在猫鼬查询返回集合之前,应用程序应该如何处理 http get 响应
- 如何根据查询返回选择 html 下拉列表
- j查询返回错误时间的日期格式
- 如何从解析查询返回对象
- 维基百科API没有为某些查询返回任何内容
- 有没有一种方法可以将每个文本区域自动调整为其大小's从数据库查询返回的数据
- 如何在 parse.com 中从查询返回值
- 你能制作Dojo'如果给定#id,则s查询返回单个节点
- 如何用javascript解析SQL查询返回
- 最大查询返回带有sequelise.js的null对象