वेब कॅप्चर आणि रूपांतरित करण्यासाठी साधने

पायथनसह वेबसाइटवरील HTML सारण्या कॅप्चर करा

पायथन एपीआय

एचटीएमएल सारण्या रूपांतरित करण्याचे अनेक मार्ग आहेत into सीएसव्ही आणि एक्सेल स्प्रेडशीट वापरुन ग्रॅबझिटची पायथन एपीआय, सविस्तर अशी काही सर्वात उपयुक्त तंत्रे आहेत. तथापि आपण सुरू करण्यापूर्वी लक्षात ठेवा की कॉल केल्यावर URLToTable, HTMLToTable or फाइलटॉटेबल पद्धती Save or SaveTo टेबल कॅप्चर करण्यासाठी मेथड कॉल केला पाहिजे. ही सेवा आपल्यासाठी योग्य आहे की नाही हे आपण त्वरीत पाहू इच्छित असल्यास आपण प्रयत्न करू शकता एचटीएमएल टेबल्स कॅप्चर करण्याचा थेट डेमो URL वरून.

मूलभूत पर्याय

खाली कोड स्निपेट निर्दिष्ट वेबपृष्ठामधील प्रथम HTML सारणी स्वयंचलितपणे रूपांतरित करते intoa CSV दस्तऐवज जो नंतर डाउनलोड किंवा विश्लेषित केला जाऊ शकतो.

grabzIt.URLToTable("https://www.tesla.com")
# Then call the Save or SaveTo method
grabzIt.HTMLToTable("<html><body><table><tr><th>Name</th><th>Age</th></tr>
    <tr><td>Tom</td><td>23</td></tr><tr><td>Nicola</td><td>26</td></tr>
    </table></body></html>")
# Then call the Save or SaveTo method
grabzIt.FileToTable("tables.html")
# Then call the Save or SaveTo method

डीफॉल्टनुसार हे त्यास ओळखत असलेल्या प्रथम सारणीचे रुपांतर करेल intओए टेबल. तथापि वेब पृष्ठामधील दुसरी सारणी एक्सएनयूएमएक्सला पास करून रूपांतरित केली जाऊ शकते tableNumberToInclude गुणधर्म

from GrabzIt import GrabzItTableOptions
from GrabzIt import GrabzItClient

grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret")

options = GrabzItTableOptions.GrabzItTableOptions()
options.tableNumberToInclude = 2

grabzIt.URLToTable("https://www.tesla.com", options)
# Then call the Save or SaveTo method
grabzIt.SaveTo("result.csv")
from GrabzIt import GrabzItTableOptions
from GrabzIt import GrabzItClient

grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret")

options = GrabzItTableOptions.GrabzItTableOptions()
options.tableNumberToInclude = 2

grabzIt.HTMLToTable("<html><body><table><tr><th>Name</th><th>Age</th></tr>
    <tr><td>Tom</td><td>23</td></tr><tr><td>Nicola</td><td>26</td></tr>
    </table></body></html>", options)
# Then call the Save or SaveTo method
grabzIt.SaveTo("result.csv")
from GrabzIt import GrabzItTableOptions
from GrabzIt import GrabzItClient

grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret")

options = GrabzItTableOptions.GrabzItTableOptions()
options.tableNumberToInclude = 2

grabzIt.FileToTable("tables.html", options)
# Then call the Save or SaveTo method
grabzIt.SaveTo("result.csv")

आपण निर्दिष्ट करू शकता targetElement विशिष्ट घटक आयडीमधील केवळ तक्त्यांचे रूपांतरण सुनिश्चित करेल असे गुणधर्म.

from GrabzIt import GrabzItTableOptions
from GrabzIt import GrabzItClient

grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret")

options = GrabzItTableOptions.GrabzItTableOptions()
options.targetElement = "stocks_table"

grabzIt.URLToTable("https://www.tesla.com", options)
# Then call the Save or SaveTo method
grabzIt.SaveTo("result.csv")
from GrabzIt import GrabzItTableOptions
from GrabzIt import GrabzItClient

grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret")

options = GrabzItTableOptions.GrabzItTableOptions()
options.targetElement = "stocks_table"

grabzIt.HTMLToTable("<html><body><table id='stocks_table'><tr><th>Name</th><th>Age</th></tr>
    <tr><td>Tom</td><td>23</td></tr><tr><td>Nicola</td><td>26</td></tr>
    </table></body></html>", options)
# Then call the Save or SaveTo method
grabzIt.SaveTo("result.csv")
from GrabzIt import GrabzItTableOptions
from GrabzIt import GrabzItClient

grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret")

options = GrabzItTableOptions.GrabzItTableOptions()
options.targetElement = "stocks_table"

grabzIt.FileToTable("tables.html", options)
# Then call the Save or SaveTo method
grabzIt.SaveTo("result.csv")

वैकल्पिकरित्या आपण वेब पृष्ठावरील सर्व टेबल्स बरोबर नेऊन कॅप्चर करू शकता includeAllTables विशेषता, तथापि हे केवळ XLSX आणि JSON स्वरूपनांसह कार्य करेल. हा पर्याय व्युत्पन्न केलेल्या स्प्रेडशीट वर्कबुकमध्ये प्रत्येक टेबलला नवीन पत्रकात ठेवेल.

from GrabzIt import GrabzItTableOptions
from GrabzIt import GrabzItClient

grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret")

options = GrabzItTableOptions.GrabzItTableOptions()
options.format = 'xlsx'
options.includeAllTables = True

grabzIt.URLToTable("https://www.tesla.com", options)
# Then call the Save or SaveTo method
grabzIt.SaveTo("result.xlsx")
from GrabzIt import GrabzItTableOptions
from GrabzIt import GrabzItClient

grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret")

options = GrabzItTableOptions.GrabzItTableOptions()
options.format = 'xlsx'
options.includeAllTables = True

grabzIt.HTMLToTable("<html><body><table><tr><th>Name</th><th>Age</th></tr>
    <tr><td>Tom</td><td>23</td></tr><tr><td>Nicola</td><td>26</td></tr>
    </table></body></html>", options)
# Then call the Save or SaveTo method
grabzIt.SaveTo("result.xlsx")
from GrabzIt import GrabzItTableOptions
from GrabzIt import GrabzItClient

grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret")

options = GrabzItTableOptions.GrabzItTableOptions()
options.format = 'xlsx'
options.includeAllTables = True

grabzIt.FileToTable("tables.html", options)
# Then call the Save or SaveTo method
grabzIt.SaveTo("result.xlsx")

एचटीएमएल टेबल्सला जेएसओएन मध्ये रूपांतरित करा

पायथन आणि ग्रॅबझिटची एचटीएमएल टेबल रूपांतरण सेवा वापरल्याने आपल्याला HTML सारण्या रूपांतरित करण्यास सक्षम करते intओ जेएसओएन. खाली दर्शविल्याप्रमाणे प्रथम चरण निर्दिष्ट करणे आहे json फॉरमॅट पॅरामीटर मध्ये त्यानंतर आम्हाला जेएसओएन मिळेल string समक्रमितपणे सह SaveTo पद्धत, त्यानंतर आपण पायथनसाठी JSON रूपांतरित करण्यासाठी आपला आवडता JSON पार्सर वापरू शकता string intओए ऑब्जेक्ट.

from GrabzIt import GrabzItTableOptions
from GrabzIt import GrabzItClient

grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret")

options = GrabzItTableOptions.GrabzItTableOptions()
options.format = "json"
options.tableNumberToInclude = 1

grabzIt.URLToTable("https://www.tesla.com", options)

json = grabzIt.SaveTo()
from GrabzIt import GrabzItTableOptions
from GrabzIt import GrabzItClient

grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret")

options = GrabzItTableOptions.GrabzItTableOptions()
options.format = "json"
options.tableNumberToInclude = 1

grabzIt.HTMLToTable("<html><body><table><tr><th>Name</th><th>Age</th></tr>
    <tr><td>Tom</td><td>23</td></tr><tr><td>Nicola</td><td>26</td></tr>
    </table></body></html>", options)

json = grabzIt.SaveTo()
from GrabzIt import GrabzItTableOptions
from GrabzIt import GrabzItClient

grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret")

options = GrabzItTableOptions.GrabzItTableOptions()
options.format = "json"
options.tableNumberToInclude = 1

grabzIt.FileToTable("tables.html", options)

json = grabzIt.SaveTo()

सानुकूल अभिज्ञापक

आपण एक सानुकूल अभिज्ञापक पास करू शकता टेबल खाली दर्शविल्या गेलेल्या पद्धती, हे मूल्य नंतर आपल्या GrabzIt पायथन हँडलरला परत केले जाईल. उदाहरणार्थ हा सानुकूल अभिज्ञापक डेटाबेस अभिज्ञापक असू शकतो, ज्यामुळे स्क्रीनशॉटला विशिष्ट डेटाबेस रेकॉर्डशी संबद्ध होऊ दिले जाते.

from GrabzIt import GrabzItTableOptions
from GrabzIt import GrabzItClient

grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret")

options = GrabzItTableOptions.GrabzItTableOptions()
options.customId = "123456"

grabzIt.URLToTable("https://www.tesla.com", options)
# Then call the Save method
grabzIt.Save("http://www.example.com/handler.py")
from GrabzIt import GrabzItTableOptions
from GrabzIt import GrabzItClient

grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret")

options = GrabzItTableOptions.GrabzItTableOptions()
options.customId = "123456"

grabzIt.HTMLToTable("<html><body><h1>Hello World!</h1></body></html>", options)
# Then call the Save method
grabzIt.Save("http://www.example.com/handler.py")
from GrabzIt import GrabzItTableOptions
from GrabzIt import GrabzItClient

grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret")

options = GrabzItTableOptions.GrabzItTableOptions()
options.customId = "123456"

grabzIt.FileToTable("example.html", options)
# Then call the Save method
grabzIt.Save("http://www.example.com/handler.py")