我正试图抓住一个房地产网站上市.它有一个aspx表单,必须在提交之前填写.
http://www.cbre.us/PropertyListings/Pages/Properties-for-Sale.aspx
然而,我所关心的只是俄勒冈州的多户住宅物业.所以这是我的第一次尝试:
driver = webdriver.Firefox()
driver.get("http://www.cbre.us/PropertyListings/Pages/Properties-for-Sale.aspx")
#Searching for multifamily residences
selectPropertyType = driver.find_element_by_id("ForSalePropertyType")
selectPropertyType.select_by_value("70")
#In the state of Oregon
selectState = driver.find_element_by_id("ForSaleState_ListBox1")
selectState.select_by_value("OR")
#Submit form
submitBtn = driver.find_element_by_id("ForSaleLooplinkSubmit")
submitBtn.click()
#Wait for results to load
WebDriverWait(driver, 5)
Run Code Online (Sandbox Code Playgroud)
当我运行这个脚本时,它会给出一个错误"找不到元素"ForSalePropertyType".我在这里做错了什么?提前谢谢.
此调用按预期工作并使 POST 成功:
public class MyService implements IMyService {
private final WebClient webClient;
private final String url;
MyService(@Qualifier("web-client") WebClient webClient,
String url) {
this.webClient = webClient;
this.url = url;
}
@SneakyThrows
@Override
public void execute(Long jobId) {
MultiValueMap<String, String> requestParms = new LinkedMultiValueMap<>();
requestParms.add("arguments", "--batchJobId=" + jobId.toString());
HttpEntity<MultiValueMap<String, String>> requestEntity =
new HttpEntity<>(requestParms, null);
final WebClient.ResponseSpec responseSpec = webClient.post()
.uri(new URI(url + "/tasks/executions"))
.body(BodyInserters.fromMultipartData(requestParms))
.exchange()
.block();
}
}
Run Code Online (Sandbox Code Playgroud)
配置类内部:
@Bean
@Qualifier("web-client")
public WebClient getWebClient() {
return WebClient.builder()
.filter(basicAuthentication("user", "pass"))
.filter(printLnFilter()) …Run Code Online (Sandbox Code Playgroud)