Пожалуйста, проявите ко мне терпение, поскольку мой родной язык - английский.
Мои опасения. Я использую 64-битный компьютер.
«Надстройки» не работают должным образом.
«Надстройки» рассчитаны на два пункта:
# 1 (scrap_Website_className)
Чтобы открыть каждую «книгу»> Удалите 19 веб-ссылок> Сохранить и закрыть книгу Затем снова откройте другую, пока не будет завершена надстройка, 184 книги.
Хорошая часть этих «надстроек».
Он обновляет все 184 файла.
Плохая сторона «надстроек».
Скопировал и вставил "html" код с некоторыми новостями.
Пожалуйста, посмотрите фото и одну из книг.
Это испортило все файлы в моей книге, сохранив их ...
«Надстройки» работают очень быстро, но портят файлы, сохраняя их.
Привет, Excel поддерживает.
Пожалуйста, проявите ко мне терпение, поскольку мой родной язык - английский.
Мои опасения. Я использую 64-битный компьютер.
«Надстройки» не работают должным образом.
«Надстройки» рассчитаны на два пункта:
# 1 (scrap_Website_className)
Чтобы открыть каждую «книгу»> Удалите 19 веб-ссылок> Сохранить и закрыть книгу Затем снова откройте другую, пока не будет завершена надстройка, 184 книги.
Хорошая часть этих «надстроек».
Он обновляет все 184 файла.
Плохая сторона «надстроек».
Скопировал и вставил "html" код с некоторыми новостями.
Пожалуйста, посмотрите фото и одну из книг.
Это испортило все файлы в моей книге, сохранив их ...
«Надстройки» работают очень быстро, но портят файлы, сохраняя их.Matrix2021
My native language is English, I hope my speech is clear.
I need your help with the add-on.
The add-in macro should ask for the name of the Sheet tab: the name Sites in the range A1 to A19. These are 19 web links, then select the data, copy only the website title and enter it in the name of another sheet tab: Name it “News” in the range “B3 to B21”.
Which confuses me. The add-on seems to work, but fills in all the data from every web page and inserts it into every cell ...
How can I get around this?
I'm not sure if the encoding given here is the source of the problem.
Sub scrap_Website () On Error Resume Next
Dim HTMLDoc As New HTMLDocument Dim ieBrowser As New InternetExplorer Dim lastRow As Byte, counter As Byte
Dim trow As Object
lastRow = WorksheetFunction.CountA (Worksheets ("Sites"). Range ("A: A"))
For counter = 1 To lastRow '' '' '' '' Zzz Application.StatusBar = "Books:" & ss & "-" & counter & "in" & lastRow & "time:" & Format (Time - ttt, "hh: nn: ss") '' '' '' '' To Open website in Internet Explorer '' '' '' 'ieBrowser.navigate Sheets ("Sites"). Range ("A" & counter) '' '' '' ' '' '' '' 'Do '' '' '' '' Wait till the Browser is loaded '' '' '' 'Loop Until ieBrowser.readyState = READYSTATE_COMPLETE '' '' '' 'Application.Wait (Now () + TimeValue ("00:00:03")) '' '' '' ' '' '' '' 'Set HTMLDoc = ieBrowser.document '' '' '' 'Sheets ("News"). Cells (counter + 2, 2) = HTMLDoc.getElementsByTagName ("h2") (0) .innerText
Sheets ("News"). Cells (counter + 2, 2) = GetHTTPResponse (Sheets ("Sites"). Range ("A" & counter)) Next
End Sub
Private Function GetHTTPResponse (ByVal sURL As String) As String Dim oXMLHTTP On Error Resume Next Set oXMLHTTP = CreateObject ("MSXML2.XMLHTTP") With oXMLHTTP .Open "GET", sURL, False .setRequestHeader "Cache-Control", "max-age = 0" .setRequestHeader "User-Agent", "Mozilla / 5.0 (Windows NT 10.0; WOW64) AppleWebKit / 537.36 (KHTML, like Gecko) Chrome / 48.0.2564.41 Safari / 537.36 OPR / 35.0.2066.10 (Edition beta)" .setRequestHeader "Accept-Encoding", "deflate" .setRequestHeader "Accept-Language", "ru-RU, ru; q = 0.8, en-US; q = 0.6, en; q = 0.4" .send GetHTTPResponse = .responseText End With Set oXMLHTTP = Nothing End Function
Please view the add-on and worksheet for your understanding
Hi Excel supporters
My native language is English, I hope my speech is clear.
I need your help with the add-on.
The add-in macro should ask for the name of the Sheet tab: the name Sites in the range A1 to A19. These are 19 web links, then select the data, copy only the website title and enter it in the name of another sheet tab: Name it “News” in the range “B3 to B21”.
Which confuses me. The add-on seems to work, but fills in all the data from every web page and inserts it into every cell ...
How can I get around this?
I'm not sure if the encoding given here is the source of the problem.
Sub scrap_Website () On Error Resume Next
Dim HTMLDoc As New HTMLDocument Dim ieBrowser As New InternetExplorer Dim lastRow As Byte, counter As Byte
Dim trow As Object
lastRow = WorksheetFunction.CountA (Worksheets ("Sites"). Range ("A: A"))
For counter = 1 To lastRow '' '' '' '' Zzz Application.StatusBar = "Books:" & ss & "-" & counter & "in" & lastRow & "time:" & Format (Time - ttt, "hh: nn: ss") '' '' '' '' To Open website in Internet Explorer '' '' '' 'ieBrowser.navigate Sheets ("Sites"). Range ("A" & counter) '' '' '' ' '' '' '' 'Do '' '' '' '' Wait till the Browser is loaded '' '' '' 'Loop Until ieBrowser.readyState = READYSTATE_COMPLETE '' '' '' 'Application.Wait (Now () + TimeValue ("00:00:03")) '' '' '' ' '' '' '' 'Set HTMLDoc = ieBrowser.document '' '' '' 'Sheets ("News"). Cells (counter + 2, 2) = HTMLDoc.getElementsByTagName ("h2") (0) .innerText
Sheets ("News"). Cells (counter + 2, 2) = GetHTTPResponse (Sheets ("Sites"). Range ("A" & counter)) Next
End Sub
Private Function GetHTTPResponse (ByVal sURL As String) As String Dim oXMLHTTP On Error Resume Next Set oXMLHTTP = CreateObject ("MSXML2.XMLHTTP") With oXMLHTTP .Open "GET", sURL, False .setRequestHeader "Cache-Control", "max-age = 0" .setRequestHeader "User-Agent", "Mozilla / 5.0 (Windows NT 10.0; WOW64) AppleWebKit / 537.36 (KHTML, like Gecko) Chrome / 48.0.2564.41 Safari / 537.36 OPR / 35.0.2066.10 (Edition beta)" .setRequestHeader "Accept-Encoding", "deflate" .setRequestHeader "Accept-Language", "ru-RU, ru; q = 0.8, en-US; q = 0.6, en; q = 0.4" .send GetHTTPResponse = .responseText End With Set oXMLHTTP = Nothing End Function
Please view the add-on and worksheet for your understandingMatrix2021