Создание сжатого (или заархивированный) папка

Зачем вам BeautifulSoup? Все это лишнее. Вот рабочий код для вашего продукта:

import scrapy


class CodeInfo(scrapy.Item):
    code = scrapy.Field()


class feedback_aliexpress_com(scrapy.Spider):
    name = 'feedback_aliexpress_com'
    domain = 'feedback.aliexpress.com'
    allowed_domains = ['feedback.aliexpress.com']
    start_urls = ['https://feedback.aliexpress.com/display/productEvaluation.htm?' +
                  'productId=32911361727&ownerMemberId=206054366&companyId=&memberType=seller&startValidDate=']
    url = 'https://feedback.aliexpress.com/display/productEvaluation.htm'

    page = 1

    def parse(self, response):
        code = CodeInfo()
        if response.css('.user-country'):
            for listing in response.css('.feedback-item'):
                code['code'] = listing.css('.user-country > b::text').extract_first()

                yield code
            self.page += 1
            self.url = 'https://feedback.aliexpress.com/display/productEvaluation.htm?productId=32911361727&ownerMemberId=206054366&page=' \
                       + str(self.page)
            yield response.follow(url=self.url, callback=self.parse)

Много лишнего))) Я знаю))) Проверьте это) сделал в спешке

6
задан pnuts 16 July 2014 в 01:30
поделиться

1 ответ

Взгляните на следующие ссылки:

http://www.rondebruin.nl/windowsxpzip.htm

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1383147&SiteID=1

Разделение важных частей от первого примера ссылки может оказаться достаточным.

Sub NewZip(sPath)
'Create empty Zip File
'Changed by keepITcool Dec-12-2005
    If Len(Dir(sPath)) > 0 Then Kill sPath
    Open sPath For Output As #1
    Print #1, Chr$(80) & Chr$(75) & Chr$(5) & Chr$(6) & String(18, 0)
    Close #1
End Sub

Function Split97(sStr As Variant, sdelim As String) As Variant
'Tom Ogilvy
    Split97 = Evaluate("{""" & _
                       Application.Substitute(sStr, sdelim, """,""") & """}")
End Function

Sub Zip_File_Or_Files()
    Dim strDate As String, DefPath As String, sFName As String
    Dim oApp As Object, iCtr As Long, I As Integer
    Dim FName, vArr, FileNameZip

    DefPath = Application.DefaultFilePath
    If Right(DefPath, 1) <> "\" Then
        DefPath = DefPath & "\"
    End If

    strDate = Format(Now, " dd-mmm-yy h-mm-ss")
    FileNameZip = DefPath & "MyFilesZip " & strDate & ".zip"

    'Browse to the file(s), use the Ctrl key to select more files
    FName = Application.GetOpenFilename(filefilter:="Excel Files (*.xl*), *.xl*", _
                    MultiSelect:=True, Title:="Select the files you want to zip")
    If IsArray(FName) = False Then
        'do nothing
    Else
        'Create empty Zip File
        NewZip (FileNameZip)
        Set oApp = CreateObject("Shell.Application")
        I = 0
        For iCtr = LBound(FName) To UBound(FName)
            vArr = Split97(FName(iCtr), "\")
            sFName = vArr(UBound(vArr))
            If bIsBookOpen(sFName) Then
                MsgBox "You can't zip a file that is open!" & vbLf & _
                       "Please close it and try again: " & FName(iCtr)
            Else
                'Copy the file to the compressed folder
                I = I + 1
                oApp.Namespace(FileNameZip).CopyHere FName(iCtr)

                'Keep script waiting until Compressing is done
                On Error Resume Next
                Do Until oApp.Namespace(FileNameZip).items.Count = I
                    Application.Wait (Now + TimeValue("0:00:01"))
                Loop
                On Error GoTo 0
            End If
        Next iCtr

        MsgBox "You find the zipfile here: " & FileNameZip
    End If
End Sub
6
ответ дан 17 December 2019 в 02:35
поделиться
Другие вопросы по тегам:

Похожие вопросы: