简体   繁体   English

使用Python提交高级eBay搜索

[英]Submitting advanced ebay searches with Python

I know there's an API among other things for scraping ebay but all I need is to submit advanced searches. 我知道还有其他用于抓取ebay的API,但我需要提交的高级搜索信息。

So, I made a function to do this, (hardcoded for now) but there's one thing I cannot get to work. 因此,我创建了一个函数来执行此操作(目前已进行了硬编码),但是有一件事我无法工作。 It's marking items as new. 它会将商品标记为新商品。

From inspecting the element on their form when items are marked as New in the advanced search form the other two fields get marked as disabled and that's the only changes I could see. 当在高级搜索表单中将项目标记为“ New时,通过检查其表单上的元素,其他两个字段被标记为“ disabled ,这是我所能看到的唯一更改。

I'm submitting the form as below and writing the content to a file so I can open it up to see the result. 我将按以下方式提交表单并将内容写入文件,以便可以打开它以查看结果。

Everything works fine and I can open the webpage and it's the correct results, but the New option is not selected. 一切正常,我可以打开网页,这是正确的结果,但是未选择“ New选项。

What is the correct way to submit this selection? 提交此选择的正确方法是什么? I've tried lots of variations and nothing I've tried works. 我尝试了很多变化,但没有尝试过。

def submit_advanced_search():

    params = {
        '_nkw': "",
        '_in_kw': 1,
        '_ex_kw': "",
        '_sacat': 20081,
        'LH_Sold': 1,
        '_udlo': 20,
        '_udhi': 250,
        'LH_ItemConditionUsed': {'disabled':'disabled'},
        'LH_ItemConditionNS': {'disabled':'disabled'},
        'LH_BIN': 1,
        'LH_FS': 1,
        'LH_Complete': 1,
    }

    content = requests.get("http://www.ebay.com/sch/i.html", params = params).content
    with open("search_result.html", "wb") as f:
        f.write(content)

Here's what worked for me. 这对我有用。 The correct field is 'LH_ItemCondition': 3 . 正确的字段是'LH_ItemCondition': 3

So the function would be: 因此,函数将是:

def submit_advanced_search():

    params = {
        '_nkw': "",
        '_in_kw': 1,
        '_ex_kw': "",
        '_sacat': 20081,
        'LH_Sold': 1,
        '_udlo': 20,
        '_udhi': 250,
        'LH_ItemCondition': 3,
        'LH_BIN': 1,
        'LH_FS': 1,
        'LH_Complete': 1,
    }

    content = requests.get("http://www.ebay.com/sch/i.html", params = params).content
    with open("search_result.html", "wb") as f:
        f.write(content)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM