CN116089746A - Browser page data export method, system and storage medium - Google Patents

Browser page data export method, system and storage medium Download PDF

Info

Publication number
CN116089746A
CN116089746A CN202211614004.XA CN202211614004A CN116089746A CN 116089746 A CN116089746 A CN 116089746A CN 202211614004 A CN202211614004 A CN 202211614004A CN 116089746 A CN116089746 A CN 116089746A
Authority
CN
China
Prior art keywords
data
target
character string
file
browser page
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211614004.XA
Other languages
Chinese (zh)
Inventor
邓峰峰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Likong Yuantong Technology Co ltd
Original Assignee
Beijing Likong Yuantong Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Likong Yuantong Technology Co ltd filed Critical Beijing Likong Yuantong Technology Co ltd
Priority to CN202211614004.XA priority Critical patent/CN116089746A/en
Publication of CN116089746A publication Critical patent/CN116089746A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/955Retrieval from the web using information identifiers, e.g. uniform resource locators [URL]
    • G06F16/9558Details of hyperlinks; Management of linked annotations
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45504Abstract machines for programme code execution, e.g. Java virtual machine [JVM], interpreters, emulators
    • G06F9/45529Embedded in an application, e.g. JavaScript in a Web browser
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

The invention provides a method, a system and a storage medium for exporting browser page data, which belong to the field of computer networks, wherein the method for exporting browser page data comprises the following steps: acquiring target data; converting the target data into CSV file format data based on JavaScript language; generating file header information; the file header information comprises a file format and a coding format; determining target character string data according to CSV file format data and file header information; generating a hyperlink label in a browser page, setting an href attribute value of the hyperlink label as target character string data, and setting a downlink attribute value of the hyperlink label as a target file name; based on the hyperlink label, the marked character string data is exported to the computer disk, the browser does not need to interact with the server, the data export speed is improved, and the resource consumption of the server is reduced.

Description

Browser page data export method, system and storage medium
Technical Field
The invention relates to the field of computer networks, in particular to a browser page data export method, a browser page data export system and a storage medium based on JavaScript.
Background
In the current browser application technology, if data in a browser page needs to be exported, the data is generally transferred to a server by the browser, then a file is generated by the server, and then the file is downloaded by the browser.
However, the method needs to rely on a server to provide functions, the browser and the server need to interact many times in the process of previewing, modifying and downloading, and when the data volume is large, the downloading speed is slow, and the resource consumption of the server is serious. And is severely limited by the network environment, the download task cannot be performed without the server.
Disclosure of Invention
The invention aims to provide a browser page data export method, a browser page data export system and a storage medium, which can reduce the resource consumption of a server and improve the data export speed.
In order to achieve the above object, the present invention provides the following solutions:
a browser page data export method, comprising:
acquiring target data;
converting the target data into CSV file format data based on JavaScript language;
generating file header information; the file header information comprises a file format and a coding format;
determining target character string data according to the CSV file format data and the file header information;
generating a hyperlink label in a browser page, setting an href attribute value of the hyperlink label as the target character string data, and setting a downlink attribute value of the hyperlink label as a target file name; the target file name is a file name stored when the target character string data is exported;
and exporting the target character string data to a computer disk based on the hyperlink label.
Optionally, the target data is table data.
Optionally, the converting the target data into CSV file format data based on JavaScript language specifically includes:
aiming at each line of the target data, adopting a character string splicing method in JavaScript language, separating each item of content of the line by using double quotation marks, and adding a line changing symbol at the tail end of the line to obtain the character string data of the line;
and splicing the character string data of each row to obtain CSV file format data.
Optionally, the file format of the file header information is csv, and the coding format is UTF-8.
Optionally, the generating the hyperlink label in the browser page specifically includes:
generating a hyperlink label by adopting a document/createElement method provided by a browser;
and loading the hyperlink label into a browser page by adopting a document. Body. App dchild method provided by the browser.
Optionally, based on the hyperlink label, the target character string data is exported to a computer disk, which specifically includes:
and calling a click method of the hyperlink label, starting a downloading program by the browser, and downloading the target character string data into a computer disk.
In order to achieve the above purpose, the present invention also provides the following solutions:
a browser page data export system, comprising:
a data acquisition unit configured to acquire target data;
the data conversion unit is connected with the data acquisition unit and is used for converting the target data into CSV file format data based on JavaScript language;
a file header generation unit for generating file header information; the file header information comprises a file format and a coding format;
the target character string determining unit is respectively connected with the data converting unit and the file header generating unit and is used for determining target character string data according to the CSV file format data and the file header information;
a hyperlink generating unit, connected to the target string determining unit, for generating a hyperlink label in a browser page, setting an href attribute value of the hyperlink label as the target string data, and setting a downlink attribute value of the hyperlink label as a target file name; the target file name is a file name stored when the target character string data is exported;
and the export unit is connected with the hyperlink generation unit and is used for exporting the target character string data to a computer disk based on the hyperlink label.
In order to achieve the above purpose, the present invention also provides the following solutions:
a computer readable storage medium storing a computer program which when executed by a processor implements the browser page data derivation method described above.
According to the specific embodiment provided by the invention, the invention discloses the following technical effects: converting the target data into CSV file format data based on JavaScript language, and generating file header information; the file header information comprises a file format and a coding format; determining target character string data according to CSV file format data and file header information, generating a hyperlink label in a browser page, setting an href attribute value of the hyperlink label as the target character string data, and setting a downlink attribute value of the hyperlink label as a target file name; and exporting the target character string data to a computer disk based on the hyperlink label. When the data is exported, the browser does not need to interact with the server, so that the data export speed is improved, and the resource consumption of the server is reduced.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions of the prior art, the drawings that are needed in the embodiments will be briefly described below, it being obvious that the drawings in the following description are only some embodiments of the present invention, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flow chart of a method for exporting browser page data according to the present invention;
fig. 2 is a schematic block diagram of a browser page data export system according to the present invention.
Symbol description:
the system comprises a data acquisition unit-1, a data conversion unit-2, a file header generation unit-3, a target character string determination unit-4, a hyperlink generation unit-5 and a derivation unit-6.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
The invention aims to provide a method, a system and a storage medium for exporting page data of a browser, wherein when a user modifies data and downloads the data, the browser does not need to interact with a server again, so that the downloading speed is improved, and network and server resources are saved. When the internet cannot be connected, the device can be used as an independent offline tool, and the content input by the user can be directly downloaded and stored as a file.
In order that the above-recited objects, features and advantages of the present invention will become more readily apparent, a more particular description of the invention will be rendered by reference to the appended drawings and appended detailed description.
Related art nouns to which the present invention relates are explained first.
Csv format: comma separated values or character separated values (command-SeparatedValues, CSV), whose file stores table data (numbers and text) in plain text form. Plain text means that the file is a sequence of characters that does not contain data (e.g., binary digits) that must be interpreted. The CSV file is composed of any number of records, the records are separated by a certain line-feed character, and can be opened by a notepad or excel.
JavaScript is a lightweight, interpreted or just-in-time programming language with functional prioritization, is based on prototype programming, a multiple-paradigm dynamic scripting language, and supports object-oriented, imperative, declarative, functional programming paradigms.
A character string is a string of characters consisting of numbers, letters, and underlining. In programming, a string is a continuous sequence of symbols or values, such as a string of symbols (a string of characters) or a string of binary digits (a string of binary digits).
HTML (hypertext markup language) is a markup language. The system comprises a series of labels, and document formats on a network can be unified through the labels, so that scattered Internet resources are connected into a logic whole.
Example 1
As shown in fig. 1, the method for exporting browser page data of the present invention includes:
s1: target data is acquired. In this embodiment, the target data is table data. The form data may be obtained via the internet or manually entered by the user.
S2: and converting the target data into CSV file format data based on JavaScript language.
Specifically, for each line of the target data, a character string splicing method in JavaScript language is adopted, each item of content of the line is separated by a double-quotation mark, and a line changing symbol (\n) is added at the tail end of the line, so that the character string data of the line is obtained. Comma separation is used from item to item. And splicing the character string data of each row to obtain CSV file format data. Each item of content of the target data refers to a piece of content in a table, which may be a word, a number, chinese or other character.
For example: "name", "age", "native", "academic" \n "Zhang Sano", "20", "Hunan", "Primary school".
S3: generating file header information. The header information includes a file format and a coding format. Because the invention processes data based on JavaScript language, the file format of the file header information is csv, and the coding format is UTF-8.
S4: and determining target character string data according to the CSV file format data and the file header information.
S5: and generating a hyperlink label in the browser page, setting an href attribute value of the hyperlink label as the target character string data, and setting a downlink attribute value of the hyperlink label as a target file name. The target file name is a file name stored when the target character string data is exported, for example: file one csv.
Specifically, an html hyperlink label is first generated by using a document. CreateElement method provided by a browser. And loading the hyperlink label into a browser page by adopting a document. Body. App dchild method provided by the browser.
In the browser environment, the address of the hyperlink label can accept the character string, the character string beginning with the data character is analyzed as a file, and the invention sets the download attribute, so that the downloading action is executed through the browser.
S6: and exporting the target character string data to a computer disk based on the hyperlink label.
Specifically, the browser directly clicks the hyperlink label in the browser page, or uses JavaScript language to call the click method of the hyperlink label, and starts a downloading program to download the target character string data as a file in csv format to the computer disk.
When the user modifies the data, the file can be downloaded without uploading the modified data to the server, so that the interaction between the browser and the server is reduced, and the downloading speed is improved. When the data volume is large and the number of the visitors is large, the server needs to process a large amount of data and has high requirements on the performance of the server.
Example two
In order to execute a corresponding method of the above embodiment to achieve the corresponding functions and technical effects, a browser page data exporting system is provided below.
As shown in fig. 2, the browser page data export system provided in this embodiment includes: a data acquisition unit 1, a data conversion unit 2, a header generation unit 3, a target character string determination unit 4, a hyperlink generation unit 5, and an export unit 6.
Wherein the data acquisition unit 1 is used for acquiring target data.
The data conversion unit 2 is connected with the data acquisition unit 1, and the data conversion unit 2 is used for converting the target data into CSV file format data based on JavaScript language.
The file header generation unit 3 is used for generating file header information; the header information includes a file format and a coding format.
The target character string determining unit 4 is connected to the data converting unit 2 and the header generating unit 3, respectively, and the target character string determining unit 4 is configured to determine target character string data according to the CSV file format data and the header information.
The hyperlink generating unit 5 is connected to the target string determining unit 4, and the hyperlink generating unit 5 is configured to generate a hyperlink label in a browser page, set an href attribute value of the hyperlink label as the target string data, and set a download attribute value of the hyperlink label as a target file name. The target file name is a file name stored when the target character string data is exported.
The export unit 6 is connected with the hyperlink generating unit 5, and the export unit 6 is used for exporting the target character string data to a computer disk based on the hyperlink label.
Compared with the prior art, the browser page data export system provided in this embodiment has the same beneficial effects as the browser page data export method provided in the first embodiment, and will not be described here again.
Example III
The present embodiment provides an electronic device, including a memory and a processor, where the memory is configured to store a computer program, and the processor runs the computer program to enable the electronic device to execute the browser page data export method of the first embodiment.
Alternatively, the electronic device may be a server.
In addition, the embodiment of the invention also provides a computer readable storage medium, which stores a computer program, and the computer program realizes the browser page data export method of the first embodiment when being executed by a processor.
In the present specification, each embodiment is described in a progressive manner, and each embodiment is mainly described in a different point from other embodiments, and identical and similar parts between the embodiments are all enough to refer to each other.
The principles and embodiments of the present invention have been described herein with reference to specific examples, the description of which is intended only to assist in understanding the methods of the present invention and the core ideas thereof; also, it is within the scope of the present invention to be modified by those of ordinary skill in the art in light of the present teachings. In view of the foregoing, this description should not be construed as limiting the invention.

Claims (8)

1. The browser page data export method is characterized by comprising the following steps of:
acquiring target data;
converting the target data into CSV file format data based on JavaScript language;
generating file header information; the file header information comprises a file format and a coding format;
determining target character string data according to the CSV file format data and the file header information;
generating a hyperlink label in a browser page, setting an href attribute value of the hyperlink label as the target character string data, and setting a downlink attribute value of the hyperlink label as a target file name; the target file name is a file name stored when the target character string data is exported;
and exporting the target character string data to a computer disk based on the hyperlink label.
2. The browser page data derivation method of claim 1, wherein the target data is tabular data.
3. The browser page data exporting method according to claim 1, wherein the converting the target data into CSV file format data based on JavaScript language specifically includes:
aiming at each line of the target data, adopting a character string splicing method in JavaScript language, separating each item of content of the line by using double quotation marks, and adding a line changing symbol at the tail end of the line to obtain the character string data of the line;
and splicing the character string data of each row to obtain CSV file format data.
4. The method according to claim 1, wherein the file header information has a file format of csv and a code format of UTF-8.
5. The method for exporting browser page data according to claim 1, wherein the generating a hyperlink label in a browser page specifically includes:
generating a hyperlink label by adopting a document/createElement method provided by a browser;
and loading the hyperlink label into a browser page by adopting a document. Body. App dchild method provided by the browser.
6. The method for exporting browser page data according to claim 1, wherein exporting the target string data to a computer disk based on the hyperlink label, specifically comprises:
and calling a click method of the hyperlink label, starting a downloading program by the browser, and downloading the target character string data into a computer disk.
7. A browser page data export system, the browser page data export system comprising:
a data acquisition unit configured to acquire target data;
the data conversion unit is connected with the data acquisition unit and is used for converting the target data into CSV file format data based on JavaScript language;
a file header generation unit for generating file header information; the file header information comprises a file format and a coding format;
the target character string determining unit is respectively connected with the data converting unit and the file header generating unit and is used for determining target character string data according to the CSV file format data and the file header information;
a hyperlink generating unit, connected to the target string determining unit, for generating a hyperlink label in a browser page, setting an href attribute value of the hyperlink label as the target string data, and setting a downlink attribute value of the hyperlink label as a target file name; the target file name is a file name stored when the target character string data is exported;
and the export unit is connected with the hyperlink generation unit and is used for exporting the target character string data to a computer disk based on the hyperlink label.
8. A computer-readable storage medium, characterized in that it stores a computer program which, when executed by a processor, implements the browser page data derivation method of any one of claims 1 to 6.
CN202211614004.XA 2022-12-15 2022-12-15 Browser page data export method, system and storage medium Pending CN116089746A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211614004.XA CN116089746A (en) 2022-12-15 2022-12-15 Browser page data export method, system and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211614004.XA CN116089746A (en) 2022-12-15 2022-12-15 Browser page data export method, system and storage medium

Publications (1)

Publication Number Publication Date
CN116089746A true CN116089746A (en) 2023-05-09

Family

ID=86185981

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211614004.XA Pending CN116089746A (en) 2022-12-15 2022-12-15 Browser page data export method, system and storage medium

Country Status (1)

Country Link
CN (1) CN116089746A (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20150082151A1 (en) * 2012-05-31 2015-03-19 Uc Mobile Limited Page display method and device
CN106777398A (en) * 2017-03-02 2017-05-31 北京微影时代科技有限公司 The generation method and device of a kind of csv file

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20150082151A1 (en) * 2012-05-31 2015-03-19 Uc Mobile Limited Page display method and device
CN106777398A (en) * 2017-03-02 2017-05-31 北京微影时代科技有限公司 The generation method and device of a kind of csv file

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
前端路上的小兵: "利用a标签导出csv文件", pages 1 - 5, Retrieved from the Internet <URL:https://www.cnblogs.com/shcrk/p/9297426.html> *
翻滚的前端程序员: "利利用HTML/HTML5中的download属性来实现数据csv文件导出用HTML/HTML5中的download属性来实现数据csv文件导出", pages 1 - 6, Retrieved from the Internet <URL:https://www.jianshu.com/p/68a21c3449d0> *

Similar Documents

Publication Publication Date Title
US10630614B2 (en) Opaque message parsing
US20060107206A1 (en) Form related data reduction
US7865544B2 (en) Method and system for providing XML-based asynchronous and interactive feeds for web applications
CN102279847B (en) Method and device for internationalizing software system
CN112650533B (en) Interface document generation method and device and terminal equipment
CN110941950B (en) Interface document generation method, device, server and storage medium
US20180260389A1 (en) Electronic document segmentation and relation discovery between elements for natural language processing
WO2018053594A1 (en) Emoji images in text messages
US20160012144A1 (en) Javascript-based, client-side template driver system
CN108885544B (en) Front-end page internationalized processing method, application server and computer-readable storage medium
CN104750663B (en) The recognition methods of text messy code and device in the page
CN112527291A (en) Webpage generation method and device, electronic equipment and storage medium
EP2874071A1 (en) Method of implementing structured and non-structured data in xml document
CN110020343B (en) Method and device for determining webpage coding format
CN116089746A (en) Browser page data export method, system and storage medium
CN105740239A (en) Translation method and system of character on webpage
CN112596688A (en) Web end custom printing method based on TinyMCE rich text
CN107885735B (en) Format-independent document translation method and system
CN103885988B (en) Export method and device, the content output system of content
US9304983B2 (en) Method and system for Xform generation and processing application integration framework
CN112199626A (en) Dynamic form generation method based on DSL layout engine
US11847406B1 (en) Natural language processing on semi-structured data
CN116992183B (en) Domestic browser adaptation compatible method based on deep learning technology
CN114448495B (en) Equipment batch adding method and device based on TDMA satellite network management
CN114547499A (en) Method for achieving SDK multi-page jump based on js protogenesis

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination