基本的import.io html搜索 [英] basic import.io html search
问题描述
因此,如果您有任何在抓取或特别是import.io方面的经验,它将有所帮助,因为import.io是我正在使用的...虽然我认为我的问题确实与JS有关... >
我真的只想将基本的html输入连接到import.io JS代码,这样我就可以进行自定义搜索
"input": {
var search_name = document.getElementsByName("search_name").value;
"search_name": search_name
}
<input name="search_name" placeholder="doesnt work :(">
这是我的...基本的工作import.io JS示例.我试图为输入名称添加一个变量并将该变量添加为搜索项,但是仅此一项是行不通的...
我联系了import.io团队,他们说他们将来会尝试简化教程,但现在尝试看一下其中包含要搜索的输入的粒子示例,但是该示例太大了让我解构只是看输入是如何工作的.
这是我上载到服务器的粒子示例,因此尽管运行缓慢,您仍可以看到它的工作原理-> http ://www.originalengine.com/scrape/
请在此处找到您的代码的修改后的版本,它似乎会产生正确的结果: http://jsfiddle.net/zNSbk/
这是修改后的功能:
var doTestQuery = function() {
// Query for tile myTestScrape2
var search_name = document.getElementById("myInput").value;
console.error(search_name);
importio.query({
"connectorGuids": [
"a2201b40-7acc-4a3d-a3ed-30e71e018ffa"
],
"input": {
"search_name": search_name
}
}, { "data": dataCallback, "done": doneCallback });
}
我要采取的步骤(不一定需要全部步骤,但这只是我正在玩的东西的摘要):
- 重新定义了提交所调用的函数,因此与我们在脚本中定义的函数不会发生冲突
- 将"search_name"变量的创建移出了importio.query的JSON参数
- 为输入分配一个ID,并将其用于
getElementById
,而不是使用名称(因为这将返回一个数组)
So if any of you have any experience with scraping or particularly import.io it will help, since import.io is what i'm using... although I think my question is just about JS really...
I really just want to connect a basic html input to the import.io JS code so I can have a custom search
"input": {
var search_name = document.getElementsByName("search_name").value;
"search_name": search_name
}
<input name="search_name" placeholder="doesnt work :(">
Heres my go... its the basic working import.io JS example. I tried to add a variable for the input name and add the variable as the search item but that alone isnt working...
I contacted the import.io team and they said they will try to make a easier tutorial in the future but for now try to look at the particle example they have which does include a input to search with but the example is too big for me to deconstruct just to see how the input works.
heres the particle example I uploaded to my server so you can see it working although its a bit slow-> http://www.originalengine.com/scrape/
Please find here a modified version of your code which seems to produce the correct result: http://jsfiddle.net/zNSbk/
This is the modified function:
var doTestQuery = function() {
// Query for tile myTestScrape2
var search_name = document.getElementById("myInput").value;
console.error(search_name);
importio.query({
"connectorGuids": [
"a2201b40-7acc-4a3d-a3ed-30e71e018ffa"
],
"input": {
"search_name": search_name
}
}, { "data": dataCallback, "done": doneCallback });
}
Steps that I took to get this working (not all may be required but it is a summary of what I was playing with):
- Redefined the function called by the submit so there's no possible collision with the one that we defined in the script
- Moved the creation of "search_name" variable out of the JSON argument to importio.query
- Assigned an ID to the input and used that with
getElementById
rather than using the name (as this would return an array)
这篇关于基本的import.io html搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!