所以我有很多教育html页面,我需要从每个页面中提取标题,我不确定应该这样做,反正我试了一下..
Function gettitle(strfile)
Set text = fso.OpenTextFile(strfile ,1)
title = ""
read = text.ReadAll
text.Close
WScript.Echo read 'Everything fine till here
strdata = InStr("<title>" ,read,1)
If strdata <> 0 Then
intstart = strdata + 7 ' "<title>" which is 7 characters long)
strtext = Mid(text,intstart,250)
For i = 1 To Len(strtext)
If Mid(strtext,i,1)= "<" Then 'Before next "<" tag , title gets extracted
Exit For
Else
title = title & Mid(strtext,i,1)
End If
Next
End if
WScript.Echo title 'I get Null value here
End Function
我获得了标题的空值。帮助将不胜感激
答案 0 :(得分:1)
我纠正了它。因此,使用此脚本,可以提取html页面中的标题。
class divlist(list):
def __init__(self, *args, **kwrgs):
super(divlist, self).__init__(*args, **kwrgs)
self.__cont_ = args[0]
self.__len_ = len(args[0])
def __floordiv__(self, other):
""" Adds the ability to floor divide list's indices """
if (isinstance(other, int) or isinstance(other, float)):
return [self.__cont_[i] // other \
for i in xrange(self.__len_)]
elif (isinstance(other, list)):
return [self.__cont_[i] // other[i] \
for i in xrange(self.__len_)]
else:
raise ValueError('Must divide by list, int or float')