我想在LinkedIn搜索页面上搜索帐户的所有第一个连接的个人资料链接.但由于页面动态加载其余内容(当您向下滚动时),我无法获得位于页面末尾的"下一页"页面按钮.
https://linkedin.com/search/results/people/?facetGeoRegion=["tr%3A0"]&facetNetwork=["F"]&origin=FACETED_SEARCH&page=YOUR_PAGE_NUMBER
我可以使用selenium和上面的链接导航到搜索页面.我想知道有多少页面可以导航它们只需更改page=
上面链接的变量.
为了实现我想要检查Next
按钮的存在.只要有下一个按钮,我就会请求下一页进行抓取.但是如果你不向下滚动直到页面底部 - 这是'下一步'按钮的位置 - 你找不到Next
按钮,也没有找到有关其他配置文件的信息,因为它们尚未加载.
以下是当您不使用firefox截屏工具向下滚动并截取整个页面的截图时的外观.
我可以通过将向下滚动操作硬编码到我的代码中并让驱动程序等待来解决这个问题visibilityOfElementLocated
.但我想知道是否还有其他方法比我的做法更好.并且如果通过该方法,驱动程序无法Next
以某种方式找到该按钮,则退出代码1退出程序.
当我向下滚动页面时检查请求时,它只是对图像等的请求,如下所示.当我向下滚动页面时,我无法弄清楚页面如何加载有关配置文件的更多信息.
以下是我在代码中实现它的方法.这个应用程序只是一个简单的实现,试图找到Next
页面上的按钮.
package com.andreyuhai;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
public class App
{
WebDriver driver;
public static void main( String[] args )
{
Bot bot = new Bot("firefox", false, false, 0, 0, null, null, null);
int pagination = 1;
bot.get("https://linkedin.com");
if(bot.attemptLogin("username", "pw")){
bot.get("https://www.linkedin.com/" +
"search/results/people/?facetGeoRegion=" …
Run Code Online (Sandbox Code Playgroud) 我创建这个问题是因为没有太多关于如何为每个循环分配这个 optind 的。
手册页说:
变量 optind 是 argv 中要处理的下一个元素的索引。系统将此值初始化为 1。
下面,我有一个从Head First C得到的简单代码,在代码中我们从“ argc ”中减去“ optind ”,我们得到剩余参数的数量,然后我们将使用它来将剩余参数打印为“成分”。
#include <unistd.h>
#include <stdio.h>
int main(int argc, char* argv[]) {
char* delivery = "";
int thick = 0 ;
int count = 0;
char ch;,
for(int i = 0; i < argc;i++){
//This is , to show the whole array and their indexes.
printf("Argv[%i] = %s\n", i, argv[i]);
}
while((ch = getopt(argc, argv, "d:t")) != -1 ){
switch(ch) …
Run Code Online (Sandbox Code Playgroud) 好吧,我相信我已经搜索得足够多了,我找不到任何解释.
当你投了char
一个int
,这是好的和明显的.
char foo = 'a';
int bar = (int)foo;
printf("%i",bar); //Outputs 97 as expected.
Run Code Online (Sandbox Code Playgroud)
但是当你尝试cast
a char *
或a char
数组时int
,编译器只会给你一个警告:
警告:从指针强制转换为不同大小的整数[-Wpointer-to-int-cast]
对于char *
你得到一个恒定int
值 - 我相信它与指针或内存有关 - 然后对于一个char
数组你总是得到一些变量int
值.
char* foo = "baz";
int bar = (int)foo;
printf("%i",bar);
char qux[]="something";
int bar2 = (int)qux;
printf("%i",bar2);
Run Code Online (Sandbox Code Playgroud)
这可能听起来像是一个不必要的问题,但我想知道原因.