找回密码
 加入
搜索
查看: 4742|回复: 5

[系统综合] 帮我找到一种修改http网址最好的办法

[复制链接]
发表于 2015-3-14 14:32:00 | 显示全部楼层 |阅读模式
有一个叫EZ的文献下载权限,简单点说就是把http原地址改为EZ地址,即可下载文献。例如:
http://www.jbc.org/content/290/6/3238.full.pdf
这个网址下载pdf文件需要权限,而挂上EZ后就可以获得权限下载了。修改方法如下,在一级域名后面加EZ即,把.sci-hub.org放在一级域名后面,变成
http://www.jbc.org.sci-hub.org/content/290/6/3238.full.pdf
但是一级域名变化多样,怎么能想出一种办法能有效的修改这种地址呢?
其他地址举例如下:

http://www.jneurosci.org/content/34/29/9574.full.pdf
http://pediatrics.aappublications.org/content/123/3/959.full.pdf
http://www.sciencedirect.com/sci ... 6312001520-main.pdf
http://graphics.tx.ovid.com/ovft ... 201311000-00019.pdf
http://link.springer.com/content ... 1605-011-1810-5.pdf
 楼主| 发表于 2015-3-14 14:40:55 | 显示全部楼层
补充说一句,目前想到的办法是根据/这个字符,第一个出现的这个/前面加上EZ,但是第一个出现的/不能是//,是不是用到正则呢?
发表于 2015-3-14 15:37:04 | 显示全部楼层
Local $Str = _
                'http://www.jneurosci.org/content/34/29/9574.full.pdf' & @CRLF & _
                'http://pediatrics.aappublications.org/content/123/3/959.full.pdf' & @CRLF & _
                'http://www.sciencedirect.com/science/article/pii/S0955286312001520/pdf?md5=9a949d9535b359e24159459b1c1f3152&pid=1-s2.0-S0955286312001520-main.pdf' & @CRLF & _
                'http://graphics.tx.ovid.com/ovftpdfs/FPDDNCOBOFIHGC00/fs047/ovft/live/gv024/00006123/00006123-201311000-00019.pdf' & @CRLF & _
                'http://link.springer.com/content/pdf/10.1007/s11605-011-1810-5.pdf' & @CRLF & _
                'http://www.jneurosci.org'
;~MsgBox(0, '原字符串', $Str)
Local $sRE = StringRegExpReplace($str, '(?<=//)(.+?)(?=/|\s|$)', '\1.sci-hub.org')
MsgBox(0, '替换结果', $sRE)
发表于 2015-3-29 12:45:53 | 显示全部楼层
本帖最后由 user030 于 2015-3-29 12:48 编辑

我刚刚从VBScript那里转到au3的怀抱中,au3基础不行,但手痒用vbs写个了,给大伙瞧瞧:

Dim TXTPath
TXTPath = "C:\Users\hulu\Desktop\URL.txt"   '存放URL的文本路径
  Set   fso = createobject("scripting.filesystemobject")   
  Set   fileread = fso.opentextfile(TXTPath,1)   
  writeTXT crlf & "修改后的URL:"
  Do   until   fileread.atendofstream   ' 遍历每一行
        strline = fileread.readline   
'       wscript.echo   strline   '显示一行内容
        If strline="" or Instr(strline,"修改后")>0 then
           exit do
        End if
        writeTXT modificateURL(strline)
  Loop   
  fread.close   
  Set   fso=nothing

Function modificateURL(byval url)   ' 修改URL
  Addtext = ".sci-hub.org"
  Array0 = split(url,"//")
  Array1 = split(Array0(1),"/")
  newURL = Array0(0) &"//"& Array1(0) & Addtext & right(url,len(url) - len(Array0(0) &"//"& Array1(0)))
  modificateURL = newURL
End Function

Function writeTXT(byval word)    ' 写入到原来的那个txt文本中
  Set fs = CreateObject("Scripting.FileSystemObject")
  Set f = fs.OpenTextFile(TXTPath, 8, false) '第二个参数 2 表示重写,如果是 8 表示追加
  f.WriteLine(word)      
  f.Close()
  Set f = nothing
  Set fs = nothing
End Function
发表于 2015-3-29 13:06:55 | 显示全部楼层
本帖最后由 netegg 于 2015-3-29 13:10 编辑
我刚刚从VBScript那里转到au3的怀抱中,au3基础不行,但手痒用vbs写个了,给大伙瞧瞧:

Dim TXTPath
T ...
user030 发表于 2015-3-29 12:45


那就试试改改
[au3]Dim $TXTPath = "C:\Users\hulu\Desktop\URL.txt"   ;存放URL的文本路径
Dim $oFso = objcreate("scripting.filesystemobject")   
Dim $oFileread = $oFso.opentextfile($TXTPath,1)   
FileWrite($TXTPath, @crlf & "修改后的URL:")
  Do
        $strline = $oFileread.readline   
;      wscript.echo   strline   ;显示一行内容
        If $strline="" or stringInstr($strline,"修改后")>0 then
           exitloop
        Endif
         FileWrite($TXTPath, modificateURL($strline)
  until   $oFileread.atendofstream     

$oFso = 0

Func modificateURL(ByRef $url)   ; 修改URL
  $Addtext = ".sci-hub.org"
  $Array0 = stringsplit($url,"//", 2)
  $Array1 = stringsplit($Array0(1),"/",2)
  Return $Array0(0) &"//"& $Array1(0) & $Addtext & stringright($url,stringlen($url) - stringlen($Array0[0] &"//"& $Array1[0]))
;  $modificateURL = newURL
EndFunc

Func writeTXT(ByRef $word)   ;写入到原来的那个txt文本中
  Dim $oFs = objcreate("Scripting.FileSystemObject")
  Dim  $of = $oFs.OpenTextFile($TXTPath, 8, false) ;第二个参数 2 表示重写,如果是 8 表示追加
  $of.WriteLine($word)      
  $of.Close()
  $of = ''
  $ofs = ''
EndFunc[/au3]
发表于 2015-3-29 20:02:38 | 显示全部楼层
回复 5# netegg


    谢谢大大,原来转换成au3是这样的,好像明白了些什么,学习了
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-2 17:43 , Processed in 0.079862 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表