有两种方法可以使用我们的 爬虫 API 检索 Wayfair 中的数据。您可以向我们提供一个完整的 URL 或通过专门建立的数据源传递参数 - 搜索 。
总览
以下是我们通过 Wayfair 支持的所有可用数据source
值的快速概览。
您可以通过选择右侧菜单的名称跳转至您喜欢的 Wayfair 页面类型。每个页面都包含参数表以及代码示例,可帮助您开始查询。
URL
wayfair
源被设计用于检索各种 Wayfair URL 中的内容。与其发送多个参数,您可以向我们提供一个转至您首选的 Wayfair 页面的直接 URL。我们不会剥离任何参数或以任何其他方式更改您的 URL。
这个数据源也支持解析数据(JSON 格式的结构化数据),只要提交的 URL 用于 Wayfair Search(SERP 页面)。如果我们不能确认这是一个 SERP 页面请求,将返回一个故障信息。
查询参数
- 必须提供的参数
代码示例
在这个示例中,我们提出了一个请求来检索一个 URL 的结果。
JSON cURL Python PHP HTTP
复制 {
"source" : "wayfair" ,
"url" : "https://www.wayfair.com/keyword.php?keyword=sofa"
}
复制 curl --user user:pass1 'https://realtime.oxylabs.io/v1/queries' -H "Content-Type: application/json"
-d '{"source": "wayfair", "url": "https://www.wayfair.com/keyword.php?keyword=sofa"}'
复制 import requests
from pprint import pprint
# Structure payload.
payload = {
'source' : 'wayfair' ,
'url' : 'https://www.wayfair.com/keyword.php?keyword=sofa'
}
# Get response.
response = requests . request (
'POST' ,
'https://realtime.oxylabs.io/v1/queries' ,
auth = ( 'user' , 'pass1' ),
json = payload,
)
# Instead of response with job status and results url, this will return the
# JSON response with results.
pprint (response. json ())
复制 <? php
$params = array (
'source' => 'wayfair' ,
'url' => 'https://www.wayfair.com/keyword.php?keyword=sofa'
);
$ch = curl_init () ;
curl_setopt ( $ch , CURLOPT_URL , "https://data.oxylabs.io/v1/queries" ) ;
curl_setopt ( $ch , CURLOPT_RETURNTRANSFER , 1 ) ;
curl_setopt ( $ch , CURLOPT_POSTFIELDS , json_encode ( $params )) ;
curl_setopt ( $ch , CURLOPT_POST , 1 ) ;
curl_setopt ( $ch , CURLOPT_USERPWD , "user" . ":" . "pass1" ) ;
$headers = array ();
$headers[] = "Content-Type: application/json" ;
curl_setopt ( $ch , CURLOPT_HTTPHEADER , $headers ) ;
$result = curl_exec ( $ch ) ;
echo $result;
if ( curl_errno ( $ch ) ) {
echo 'Error:' . curl_error ( $ch ) ;
}
curl_close ( $ch ) ;
?>
复制 # URL has to be encoded to escape `&` and `=` characters:
# URL: https://www.wayfair.com/keyword.php?keyword=sofa
# Encoded URL: https%3A%2F%2Fwww.wayfair.com%2Fkeyword.php%3Fkeyword%3Dsofa
https://realtime.oxylabs.io/v1/queries?source=google&url=https%3A%2F%2Fwww.wayfair.com%2Fkeyword.php%3Fkeyword%3Dsofa&access_token=12345abcde
以上示例使用了 Realtime 集成方法。如果您想在您的查询中使用一些其他集成方法(如推拉 或代理端 点 ),请参考集成方法 部分。
搜索
wayfair_search
源设计用于检索 Wayfair 搜索结果(SERP)。
查询参数
参数 描述 默认值 每页中要检索的结果数。可用值:24
, 48
, 96
- 必须提供的参数
代码示例
在以下代码示例中,我们提出了一个请求来检索 4
页 wayfair.com
搜索结果的页面,从第 2
页开始, 搜索词为 sofa
。
JSON cURL Python PHP HTTP
复制 {
"source" : "wayfair_search" ,
"query" : "sofa" ,
"start_page" : 2 ,
"pages" : 4
}
复制 curl --user user:pass1 'https://realtime.oxylabs.io/v1/queries' -H "Content-Type: application/json"
-d '{"source": "wayfair_search", "query": "sofa", "start_page": 2, "pages": 4}'
复制 import requests
from pprint import pprint
# Structure payload.
payload = {
'source' : 'wayfair_search' ,
'query' : 'sofa' ,
'start_page' : 2 ,
'pages' : 4
}
# Get response.
response = requests . request (
'POST' ,
'https://realtime.oxylabs.io/v1/queries' ,
auth = ( 'user' , 'pass1' ),
json = payload,
)
# Print prettified response to stdout.
pprint (response. json ())
复制 <? php
$params = array (
'source' => 'wayfair_search' ,
'query' => 'sofa' ,
'start_page' => 2 ,
'pages' => 4
);
$ch = curl_init () ;
curl_setopt ( $ch , CURLOPT_URL , "https://realtime.oxylabs.io/v1/queries" ) ;
curl_setopt ( $ch , CURLOPT_RETURNTRANSFER , 1 ) ;
curl_setopt ( $ch , CURLOPT_POSTFIELDS , json_encode ( $params )) ;
curl_setopt ( $ch , CURLOPT_POST , 1 ) ;
curl_setopt ( $ch , CURLOPT_USERPWD , "user" . ":" . "pass1" ) ;
$headers = array ();
$headers[] = "Content-Type: application/json" ;
curl_setopt ( $ch , CURLOPT_HTTPHEADER , $headers ) ;
$result = curl_exec ( $ch ) ;
echo $result;
if ( curl_errno ( $ch ) ) {
echo 'Error:' . curl_error ( $ch ) ;
}
curl_close ( $ch ) ;
?>
复制 https://realtime.oxylabs.io/v1/queries?source=wayfair_search&query=sofa&start_page=2&pages=4&access_token=12345abcde
以上示例使用了 Realtime 集成方法。如果您想在您的查询中使用一些其他集成方法(如推拉 或代理端 点 ),请参考集成方法 部分。