我正在寻找一种通过LinkedIn高级搜索功能自动连接到人们的方法。从“你可能认识的人”页面上有很多关于这方面的信息,但我只能找到下面的代码,这些代码适用于高级搜索页面,但没有。有什么想法吗?
setInterval(function () {var x = $(‘.primary-action-button’);for (var i = 0; i < x.length; i++){if(x[i].innerHTML == “Connect”) {x[i].click()}}var y = $(‘a.page-link’);y[y.length — 1].click();}, 1000)
答案 0 :(得分:1)
var i;
var res;
var str1 = "ember";
for(i=0;i < 10000;i++)
{
try {
res = str1.concat(i);
if(document.getElementById(res).innerText == "Connect"){
document.getElementById(res).click();}
console.log(document.getElementById(res).innerText == "Connect");
}
catch(err) {
}
}
答案 1 :(得分:0)
代码中有一些非法令牌,例如‘,’,“,”
以及减号—
,它们不是用于解析JavaScript的代码。它们应分别替换为',',",",-
。
当您从PDF中复制文本或非纯文本格式的文本时,通常会发生此问题。
setInterval(function () {
var x = $('.primary-action-button');
for (var i = 0; i < x.length; i++){
if(x[i].innerHTML == "Connect") {
x[i].click()
}
}
var y = $('a.page-link');
y[y.length - 1].click();
}, 1000)
&#13;
答案 2 :(得分:0)
用于在Linkedin自定义搜索中与其他人联系1-3rd
您好,开发人员,您好吗?
我落后于Chrome或Firefox的插件,该插件执行了此类操作,但是我只发现了无用或已停产的代码。
因此,我决定创建自己的代码来完成此自动化工作,并分页并添加自动注释。
如果您正在阅读此评论,则发布日期为2019.06.05。该代码旨在与Linkedin的当前版本兼容,但是随着业务社交网络的设计/结构发生变化,可能需要对其进行更新。
如何使用?
简单,打开Linkedin,按公司,服务或行业进行搜索。在Google Chrome浏览器中按F12键,在开发者控制台中粘贴代码,然后按Enter。
PS:请不要忘记在Linkedin(脚本)类中更改自定义注释消息。
(Linkedin = {
release: '1.0.5 stable',
data: {},
config: {
autoStart: true,
inspectorSpeed: 5000,
sendSpeed: 4000,
pagerSpeed: 10000,
scrollDownAuto: 600,
debug: true,
message: 'Your custom note message (max 300 length)'
},
setEvents: function () {
this.debug('set events');
},
debug: function (a) {
if (this.config.debug && typeof console === 'object') {
console.log(a)
}
},
init: function () {
this.debug('start script');
this.setDefaults();
this.setEvents();
if (this.config.autoStart) {
this.inspect();
}
},
complete: function () {
this.debug('script complete');
},
sleep: function (a) {
this.setScroll();
var start = new Date().getTime();
for (var i = 0; i < 1e7; i++) {
if ((new Date().getTime() - start) > a) {
break;
}
}
},
totalRows: function () {
return $('.search-result').length;
},
compile: function () {
this.data.pageButtons = $("button.search-result__action-button").filter(function () {
return $.trim($(this).text()) === "Connect";
});
this.data.pageButtonTotal = this.data.pageButtons.length;
},
stop: function () {
clearInterval(Linkedin.data.pageInterval);
clearInterval(Linkedin.data.nextInterval);
},
setDefaults: function () {
this.stop();
this.data = {
pageInterval: null,
nextInterval: null,
pageIndex: (this.data.pageIndex) ? this.data.pageIndex : 1,
pageButtons: {},
pageButtonIndex: 0,
pageButtonTotal: 0,
lockInpect: false,
lockClick: false
};
},
sendInvites: function () {
this.compile();
this.setScroll();
this.debug('validing');
if (this.data.pageButtonTotal === 0 || this.data.lockInpect === true) {
this.sleep(this.config.sendSpeed);
return this.nextPage();
}
this.sleep(this.data.speed);
this.debug('sending invite ' + (this.data.pageButtonIndex + 1) + '/' + this.data.pageButtonTotal);
var button = this.data.pageButtons[this.data.pageButtonIndex];
this.debug('clicking connect');
$(button).click();
this.sleep(Linkedin.config.sendSpeed);
this.debug('adding a note');
$("button:contains('Add a note')").click();
this.sleep(Linkedin.config.sendSpeed);
this.debug('write a note');
var textArea = $('textarea[id="custom-message"]');
textArea.val(this.config.message);
this.sleep(Linkedin.config.sendSpeed);
this.debug('send click');
$("button:contains('Send invitation')").click();
this.sleep(Linkedin.config.sendSpeed);
this.debug('close window');
$("button:contains('Cancel')").click();
this.sleep(Linkedin.config.sendSpeed);
this.debug('ignore confirm mail');
if ($('[id=email]').length) {
$('.send-invite__cancel-btn').click();
}
this.sleep(Linkedin.config.sendSpeed);
this.stop();
if (this.closeAll() && this.data.pageButtonIndex === (this.data.pageButtonTotal - 1)) {
return this.nextPage();
} else if (this.data.lockInpect === false && this.data.pageButtonIndex < (this.data.pageButtonTotal - 1)) {
this.data.pageButtonIndex++;
return this.sendInvites();
} else {
this.debug('waiting page overflow down');
this.sleep(Linkedin.config.sendSpeed);
return this.nextPage();
}
},
nextPage: function () {
Linkedin.debug('find page');
Linkedin.setScroll();
Linkedin.data.lockInpect = true;
Linkedin.data.nextInterval = setInterval(function () {
var pagerButton = $('.artdeco-pagination__button.artdeco-pagination__button--next[id^=ember]');
Linkedin.debug('check page links...');
if (pagerButton.length === 0) {
return false;
}
if (Linkedin.data.lockClick === false) {
Linkedin.debug('call next page (link)');
Linkedin.data.lockClick = true;
pagerButton.trigger('click');
}
Linkedin.checkRequest();
}, Linkedin.config.pagerSpeed);
},
checkRequest: function () {
var currentPageIndex = Linkedin.getURIParam('page');
if (currentPageIndex !== Linkedin.data.pageIndex) {
Linkedin.data.pageIndex = currentPageIndex;
Linkedin.setDefaults();
Linkedin.debug('page ready');
return Linkedin.inspect();
}
},
closeAll: function () {
if ($('.send-invite__cancel-btn').length) {
$('.send-invite__cancel-btn').click();
}
return (!$('.send-invite__cancel-btn:visible').length);
},
setScroll: function (a) {
$('body').click();
window.scrollTo(0, $(window).scrollTop() + ((a) ? a : Linkedin.config.scrollDownAuto));
},
inspect: function () {
this.debug('inspect elements');
this.data.pageInterval = setInterval(function () {
Linkedin.setScroll(Linkedin.config.scrollDownAuto);
if (Linkedin.totalRows() >= 20 && $('.artdeco-pagination__button.artdeco-pagination__button--next[id^=ember]').length) {
clearInterval(Linkedin.data.pageInterval);
Linkedin.sendInvites();
} else {
Linkedin.debug('listening..');
}
}, Linkedin.config.inspectorSpeed);
},
getURIParam: function (name) {
name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
var regex = new RegExp('[\\?&]' + name + '=([^&#]*)');
var results = regex.exec(location.search);
return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
}
}).init();
答案 3 :(得分:0)
看来这不再起作用了。
似乎LinkedIn不再使用jQuery。
VM4213:158 Uncaught ReferenceError: $ is not defined
at Object.setScroll (<anonymous>:158:9)
at <anonymous>:164:22