请求 URL 的 Python 代码:
agent = {"User-Agent":'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36'} #using agent to solve the blocking issue
response = requests.get('https://www.naukri.com/jobs-in-andhra-pradesh', headers=agent)
#making the request to the link
Run Code Online (Sandbox Code Playgroud)
打印 html 时的输出:
<!DOCTYPE html>
<html>
<head>
<title>Naukri reCAPTCHA</title> #the title in the actual title of the URL that I am requested for
<meta name="robots" content="noindex, nofollow">
<link rel="stylesheet" href="https://static.naukimg.com/s/4/101/c/common_v62.min.css" />
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
</head>
</html>
Run Code Online (Sandbox Code Playgroud) 我创建了一个脚本来使用请求登录到linkedin。剧本做得很好。
登录后,我使用这个 url从那里https://www.linkedin.com/groups/137920/抓取了这个名字Marketing Intelligence Professionals,你可以在这张图片中看到。
该脚本可以完美地解析名称。但是,我现在想要做的是抓取连接到位于此图像中See all显示的页面底部的按钮的链接。
群组链接 you gotta log in to access the content
到目前为止,我已经创建了(它可以抓取第一张图片中显示的名称):
import json
import requests
from bs4 import BeautifulSoup
link = 'https://www.linkedin.com/login?fromSignIn=true&trk=guest_homepage-basic_nav-header-signin'
post_url = 'https://www.linkedin.com/checkpoint/lg/login-submit'
target_url = 'https://www.linkedin.com/groups/137920/'
with requests.Session() as s:
s.headers['User-Agent'] = 'Mozilla/5.0 (Windows NT 6.1; ) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36'
r = s.get(link)
soup = BeautifulSoup(r.text,"lxml")
payload = {i['name']:i.get('value','') for i in soup.select('input[name]')}
payload['session_key'] = 'your email' #put your username …Run Code Online (Sandbox Code Playgroud) python beautifulsoup web-scraping python-3.x python-requests
我可以使用 Outlook 和以下脚本发送电子邮件,但如果我尝试发送附件,则会出现错误。
文件名_Email.xlsx
NAME EMAIL
Roy Roy@gmail.com
Jack Jack@gmail.com
Run Code Online (Sandbox Code Playgroud)
Python脚本
import win32com.client as win32
import pandas as pd
email_list = pd.read_excel(r'C:\Users\roy\Name_Email.xlsx')
names = email_list['NAME']
emails = email_list['EMAIL']
for i in range(len(emails)):
name = names[i]
email = emails[i]
outlook = win32.Dispatch('outlook.application')
mail = outlook.CreateItem(0)
mail.To = email
mail.Subject = 'Message subject'
mail.Body = 'Hello ' + name
attachment = "hosts.txt"
mail.Attachments.Add(attachment)
mail.Send()
Run Code Online (Sandbox Code Playgroud)
我收到错误:
pywintypes.com_error: (-2147352567, 'Exception occurred.', (4096, 'Microsoft Outlook', 'Cannot find this file. Verify the path and file name …Run Code Online (Sandbox Code Playgroud) 我怎么能写代码说.
Dim xlApp As Excel.Application
Dim xlWorkbook As Excel.Workbook
Dim xlWorksheet As Excel.Worksheet
Run Code Online (Sandbox Code Playgroud)
如果一个excel工作簿已经打开然后....
Set xlApp = GetObject(, "Excel.Application")
elseif xlApp is nothing then
Set xlApp = New Excel.Application
xlApp.Visible = True
Set xlWorkbook = xlApp.Workbooks.Open("E:\InspectionCreator\InspectionSheet.xlsx")
End if
Run Code Online (Sandbox Code Playgroud)
我不希望它必须是一个特定的工作簿,我似乎无法在互联网上找到任何工作簿.任何帮助都是极好的.
一个简单的问题,但我已经找到答案了.我有一个垂直格式的大型地址列表,我想要更改为水平列表.下面是一个例子,基本上我想将单元格更改为水平而不是垂直向下读取,括号中每个部分的单元格值:
垂直清单:
(A1) 12 Norton Street
(A2) Warwick
(A3) Warwickshire
(A4) CV12 3SE
Run Code Online (Sandbox Code Playgroud)
水平清单:
(A1) 12 Norton Street (B1) Warwick (C1) Warwickshire (D1)CV12 3SE
Run Code Online (Sandbox Code Playgroud)
有人有什么建议吗?
我有一个变量,其中包含一个由用户选择的范围值.
如何检查它是否有值?
我试过这些:
If variable_name.Value = Empty then ....
If variable_name.Value = " " then ...
Run Code Online (Sandbox Code Playgroud)
但是,当变量包含文本,数字或空格等数据时,这些只会很好.
任何的想法?
我正在尝试使用treeView创建菜单.这是我第一次使用treeView并在几个网站上阅读它.
在动作事件方面我遇到了一些问题.我想要做的基本上是当用户点击树视图中的节点时触发和事件到目前为止我有以下内容:
TreeItem<String> rootItem = new TreeItem<String>("Navigation");
TreeItem<String> statistics = new TreeItem<String>("Statistics");
TreeItem<String> clan = new TreeItem<String>("Clan page");
clan.addEventHandler(MouseEvent, new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
// TODO Auto-generated method stub
}
});
rootItem.getChildren().add(statistics);
rootItem.getChildren().add(clan);
TreeView<String> tree = new TreeView<String>(rootItem);
Run Code Online (Sandbox Code Playgroud)
可悲的是,这似乎不起作用.
有没有什么办法可以在不改变类型的情况下为我的个别项添加一个clicklistener甚至是一个?actionlistenertreeViewtreeItemsButton
这是关于excel中的宏.
当按下组合键(即触发宏)时,我需要对具有ActiveCell的行的第1列到第10列进行一些格式更改.
目前我正在选择整行
ActiveCell.EntireRow.Select
Run Code Online (Sandbox Code Playgroud)
但是,我只需要选择第1行到第10行.我认为它应该是类似的
ActiveCell.Range(1, 10).Select
Run Code Online (Sandbox Code Playgroud)
但这不起作用.
为了清楚起见,我已经读过了
ActiveCell.Offset(5, -4).Select
Run Code Online (Sandbox Code Playgroud)
但这不符合我的情况.ActiveCell可以是行的任何列,因此硬编码的偏移量无济于事.
所以,那里的优秀大师,我希望这是一个快速的东西,只是我不知道怎么找不到答案.请帮忙.
列A有Apples,Oranges,Pears多次.
B列count对抗它们(注意,其中一些可能是空白的).
我正在寻找一个公平的数字,Apples以及Oranges它们count既不是空白也不是0.
我尝试了下面的公式,但我得到的Apples只是:
=COUNTIFS(A1:A21,{"Apples","Oranges"},B1:B21,">0")
Run Code Online (Sandbox Code Playgroud) 当我尝试在excel中使用VBA制作动态公式时,我收到此错误消息.
这条线很好:
ActiveCell.Value = "IF(SUM(" & Range("A1:A5").Address & ")*0,1>" & Range("B1").Address & ";" & Range("C1").Address & ";SUM(" & Range("A1:A5").Address & ")*0,1)*-1"
Run Code Online (Sandbox Code Playgroud)
如果我在这样的IF语句前添加=,我得到错误.
ActiveCell.Value = "=IF(SUM(" & Range("A1:A5").Address & ")*0,1>" & Range("B1").Address & ";" & Range("C1").Address & ";SUM(" & Range("A1:A5").Address & ")*0,1)*-1"
Run Code Online (Sandbox Code Playgroud)
如果我在测试第一个代码后添加=符号.它在excel中运行良好.我在这做错了什么?
不要介意范围和东西.它们只是占位符,使示例与我的代码尽可能相似.
excel ×6
excel-vba ×4
vba ×4
python ×3
web-scraping ×2
email ×1
excel-2010 ×1
java ×1
javafx ×1
list ×1
outlook ×1
python-3.x ×1
win32com ×1