作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想从此 link 中提取带有 rvest 的电子邮件然而,有一个 JavaScript 屏蔽了 mailto href
如何改进以下代码?
uni<- c("https://uni-tuebingen.de/fakultaeten/philosophische-fakultaet/fachbereiche/asien-orient-wissenschaften/indologie/mitarbeiter/")
r<-read_html(uni)
a <- r %>%
html_nodes("a") %>%
html_attrs() %>%
as.character() %>%
str_subset("mailto:") %>%
str_remove("mailto:")
提前致谢
最佳答案
def decryptCharcode(n, start, end, offset):
n = ord(n) + offset
if (offset > 0 and n > end):
n = start + (n - end - 1)
elif (offset < 0 and n < start):
n = end - (start - n - 1)
return ''.join(map(chr, [n]))
def decryptString(enc, offset):
dec = ""
length = len(enc)
for i in range(length-3):
n = enc[i]
if (0x2B <= ord(n) <= 0x3A):
dec += decryptCharcode(n, 0x2B, 0x3A, offset)
elif 0x40 <= ord(n) <= 0x5A:
dec += decryptCharcode(n, 0x40, 0x5A, offset)
elif (0x61 <= ord(n) <= 0x7A):
dec += decryptCharcode(n, 0x61, 0x7A, offset)
else:
dec += enc[i]
return dec
email = "%27ocknvq%2Cuvqemgt0ygtpgtBdnwgykp0ej%27"
if "%27ocknvq%2C" in email:
email = email.replace("%27ocknvq%2C","")
email = decryptString(email,-2)
if "%3A%0D" in email:
email=email.replace("%3A%0D","-")
打印(电子邮件)
我将JS代码转换为Python。引用:https://gist.github.com/InsanityMeetsHH/c38f513f28d6f9b778912f110c565348
关于使用 <a href="javascript :linkTo_UnCryptMailto(%27ocknvq%2Cjgkmg0qdgtnkpBwpk%5C%2Fvwgdkpigp0fg%27) 接收邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66551024/
我是一名优秀的程序员,十分优秀!