CN109542756B - Method and device for automatically configuring script, electronic equipment and storage medium - Google Patents

Method and device for automatically configuring script, electronic equipment and storage medium Download PDF

Info

Publication number
CN109542756B
CN109542756B CN201811152520.9A CN201811152520A CN109542756B CN 109542756 B CN109542756 B CN 109542756B CN 201811152520 A CN201811152520 A CN 201811152520A CN 109542756 B CN109542756 B CN 109542756B
Authority
CN
China
Prior art keywords
information
target database
server
url
target
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.)
Active
Application number
CN201811152520.9A
Other languages
Chinese (zh)
Other versions
CN109542756A (en
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.)
Ping An Life Insurance Company of China Ltd
Original Assignee
Ping An Life Insurance Company of China 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 Ping An Life Insurance Company of China Ltd filed Critical Ping An Life Insurance Company of China Ltd
Priority to CN201811152520.9A priority Critical patent/CN109542756B/en
Publication of CN109542756A publication Critical patent/CN109542756A/en
Application granted granted Critical
Publication of CN109542756B publication Critical patent/CN109542756B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • 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

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

A method of automating configuration scripts, the method comprising: receiving input target database information; automatically connecting to the target database, and acquiring an information table in the target database, wherein the information table comprises product information and URL (uniform resource locator) information corresponding to the product information; extracting server information in the URL information; receiving input target server information; and replacing the server information in the extracted URL information with the target server information. The invention also provides a device for automatically configuring the script, the electronic equipment and a storage medium. The device is equivalent to an automatic testing tool, can realize one-key modification of the product URL information in the information table in the target database according to the user requirement, and solves the problem that manual resource occupation is greatly caused by manual modification of the product URL information in the comparison table.

Description

Method and device for automatically configuring script, electronic equipment and storage medium
Technical Field
The invention relates to the technical field of testing, in particular to a method and a device for automatically configuring a script, electronic equipment and a storage medium.
Background
With the continuous development of internet technology, more and more network software is put into use. In the development process of software, the test work plays a significant role in the whole development life cycle. Software testing refers to the process of testing various functions of software to find defects present therein. In the conventional software testing technology, a manual intervention stage exists, a tester needs to manually set a test case and various testing actions included in the test case, manually run a test, manually compare test results and judge whether the test is successful according to the comparison result. For example, in the testing process of the mil-shop subsystem, product link URLs in the database need to be manually changed, but the product link URLs in the subsystem have a lot of data, and are troublesome to manually change, occupy a large amount of manual resources, prolong the software testing time, and reduce the testing efficiency.
Disclosure of Invention
In view of the foregoing, there is a need for a method, an apparatus, an electronic device, and a storage medium for automatically configuring a script, which can modify product URL information in an information table in a target database by one key according to a user requirement.
A first aspect of the invention provides a method of automatically configuring a script, the method comprising:
receiving input target database information;
automatically connecting to the target database, and acquiring an information table in the target database, wherein the information table comprises product information and URL (uniform resource locator) information corresponding to the product information;
extracting server information in the URL information;
receiving input target server information; and
and replacing the server information in the extracted URL information with the target server information.
Preferably, the URL information includes: resource type, domain name system host name or IP address of the server storing the resource, and resource file name.
Preferably, extracting the server information in the URL information in the information table by a regular expression includes:
importing a regular expression module through import re;
creating a Regex object through re.composition () function;
using search () or findall () method of Regex object to transfer into domain name system host name or IP address of the server storing resource to be searched, and returning a Match object; and
and calling a group () method of the Match object, and returning the matched server information.
Preferably, after the step of replacing the server information in the extracted URL information with the target server information, the method further includes:
and splicing the target server information and the resource type and the resource file name in the corresponding URL information in the information table into complete URL information.
Preferably, the target database information includes an address of the target database, a name of the target database, and a port.
Preferably, the step of automatically connecting to the target database and acquiring the information table in the target database includes:
importing a cx _ Oracle module;
connecting the target database according to the address of the target database;
obtaining cursor;
using cursor to perform corresponding operation, wherein the corresponding operation comprises an operation of reading an information table in the target database;
closing the cursor;
the connection is closed.
Preferably, the target server information includes new website information provided by the user for the products in the target database.
A second aspect of the present invention provides an apparatus for automated configuration of scripts, the apparatus comprising:
the first receiving module is used for receiving input target database information;
the connection module is used for automatically connecting to the target database and acquiring an information table in the target database, wherein the information table comprises product information and URL (uniform resource locator) information corresponding to the product information;
the extraction module is used for extracting the server information in the URL information;
the second receiving module is used for receiving input target server information; and
and the processing module is used for replacing the server information in the extracted URL information with the target server information.
A third aspect of the invention provides an electronic device comprising a processor and a memory, the processor being configured to implement the method of automatically configuring a script when executing a computer program stored in the memory.
A fourth aspect of the invention provides a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, implements the method of automatically configuring scripts.
The method is automatically connected to a target database through a Python technology, product URL information in an information table in the target database is obtained, a server address in the product URL information is automatically extracted according to a regular expression, a new server address is received, and the extracted server address is updated to be the new server address. Therefore, the product URL information in the information table in the target database is modified in a one-key mode according to the user requirements, and the problem that a large amount of manual resources are occupied due to the fact that the product URL information in the comparison table is manually changed is solved. The software testing time is shortened, and the testing efficiency is improved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the provided drawings without creative efforts.
FIG. 1 is a flowchart of a method for automatically configuring scripts according to an embodiment of the present invention.
FIG. 2 is a functional block diagram of an apparatus for automatically configuring scripts according to a second embodiment of the present invention.
Fig. 3 is a schematic diagram of an electronic device according to a third embodiment of the present invention.
The following detailed description will further illustrate the invention in conjunction with the above-described figures.
Detailed Description
In order that the above objects, features and advantages of the present invention can be more clearly understood, a detailed description of the present invention will be given below with reference to the accompanying drawings and specific embodiments. It should be noted that the embodiments of the present invention and features of the embodiments may be combined with each other without conflict.
In the following description, numerous specific details are set forth to provide a thorough understanding of the present invention, and the described embodiments are merely a subset of the embodiments of the present invention, rather than a complete embodiment. All other embodiments, which can be obtained by a person skilled in the art without making any creative effort based on the embodiments in the present invention, belong to the protection scope of the present invention.
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs. The terminology used in the description of the invention herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention.
The terms "first," "second," and "third," etc. in the description and claims of the present invention and the above-described drawings are used for distinguishing between different objects and not for describing a particular order. Furthermore, the terms "comprises" and any variations thereof, are intended to cover non-exclusive inclusions. For example, a process, method, system, article, or apparatus that comprises a list of steps or elements is not limited to only those steps or elements listed, but may alternatively include other steps or elements not listed, or inherent to such process, method, article, or apparatus.
The method for automatically configuring the script is applied to one or more electronic devices. The method for automatically configuring scripts can also be applied to a hardware environment consisting of an electronic device and a server connected with the electronic device through a network. Networks include, but are not limited to: a wide area network, a metropolitan area network, or a local area network. The method for automatically configuring the script can be executed by a server or an electronic device; or may be performed by both the server and the electronic device.
For the electronic device which needs to perform the method for automatically configuring the script, the application program exception handling function provided by the method of the present invention can be directly integrated on the electronic device, or a client for implementing the method of the present invention is installed. For another example, the method provided by the present invention may also be run on a device such as a server in the form of a Software Development Kit (SDK), an interface for automatically configuring a script function is provided in the form of an SDK, and an electronic device or other devices may implement automatic configuration of a script through the provided interface.
Example one
FIG. 1 is a flowchart of a method for automatically configuring scripts, according to an embodiment of the present invention. The execution sequence in the flow chart can be changed and some steps can be omitted according to different requirements.
And S11, receiving input target database information.
Specifically, target database information externally input is received through a display unit or an input unit of the electronic device. The target database information includes an address of the target database, a target database name, and a port. In other embodiments, the target database information further includes a user name and a login password for logging in the database.
The target database can be Sybase, DB2, oracle, SQL server, etc. In this embodiment, the target database is an Oracle database.
The Display unit may be a Liquid Crystal Display (LCD) or an Organic Light-Emitting Diode (OLED) Display. The display unit may be used to display an application program interface. The display unit may also receive the input information, for example, a user may input information in the display unit through an input device such as a finger or a touch pen.
The user can interact with the electronic device through the input unit. For example, information input by a user is received. The user can interact with the electronic equipment through the input unit in a non-contact input mode. Such as motion input, voice input, etc. When the user interacts with the electronic device through voice input, the input unit may be a microphone. The input unit can also be an external remote control unit, and the remote control unit sends a control command to the electronic equipment in a wireless or wired communication mode.
The input unit may also be a mechanical key input unit, such as a key, a stick, a flywheel input key, etc.
In this embodiment, the electronic device may include, but is not limited to, a Personal Computer (PC), a Personal Digital Assistant (PDA), a wireless handheld device, a Tablet Computer (Tablet Computer), a smart phone, and the like.
And S12, automatically connecting to the target database, and acquiring an information table in the target database, wherein the information table comprises product information and URL (uniform resource locator) information corresponding to the product information.
The Uniform Resource Locator (URL) information is a compact representation of the location and access method of a Resource available from the internet, and is an address of a standard Resource on the internet. Sometimes colloquially referred to as a web address (web site). Each file on the internet has a unique URL.
The base URL consists of three parts: resource type, domain name system host name or IP address of the server storing the resource, and resource file name.
The general syntax format of a URL is:
protocol:// hostname [: port ]/path/[; parameters ] [? query ] # fragment. Wherein, with brackets [ ] is optional.
The protocol is a transport mode/protocol specified for use to tell the browser how to handle the file to be opened. The most common mode is Hypertext Transfer Protocol (HTTP), other protocols include file Transfer Protocol (ftp), email address (mailto), etc.
The hostname refers to the domain name system host name or IP address of the server where the resource is stored.
The port number (port) is an integer, which is optional. When omitted, a default port is used, and various transport protocols have default port numbers, such as http with a default port number of 80. If the input is omitted, the default port number is used. Sometimes, for security or other reasons, the port may be redefined on the server, i.e. using a non-standard port number, in which case the port number entry cannot be omitted from the URL.
The hostname may also contain the user name and password necessary to log in to the server.
The path includes a path and a file name, and refers to a path to the file and a name of the file itself. The path segments contain hierarchical path definitions, generally with different segments separated by slashes (/).
The parameters are used to specify the options of a particular parameter.
The query portion query is typically used to convey the parameters needed to dynamically query the database on the server.
In this embodiment, the information table describes different URL information corresponding to different products.
For example, when the product is a television, the URL information corresponding to the television is http:// card all. Pingan. Com/lookup product detailinfo. Shtmlpructid =00480787 and keyswords = & shelveid =00480787;
when the product is an oximeter, the URL information corresponding to the oximeter is http:// card all. Pingan. Com/lookup UpproductDetailinInfo. ShtmlProductId =00478872 and keywords = & shelveId =00478872.
In this embodiment, a python technique may be used to implement the connection to the target database. Specifically, the aim of automatically connecting to the target database is achieved through the cx _ Oracle module of the Python.
First, the cx _ Oracle module is downloaded and installed, after which the target database can be connected and used. The process is as follows:
importing a cx _ Oracle module;
connecting a database;
obtaining cursor;
performing various operations by using cursor;
closing the cursor;
the connection is closed.
Wherein the target database is connected by a cx _ oracle.connect (e.g., "username/password @ Oracle server IP/Oracle's SERVICE _ NAME") statement.
For example:
import cx _ Oracle # import cx _ Oracle Module
conn = cx _ oracle. Connect ('load/123456 @ localhost/orcl') # connect database
currsor () c = conn
Execute ('select sysdate from dual') # uses cursor to perform various operations
Fetch () read operation result
close # closed cursor
close () # close linkage
In this embodiment, the target database may also be read and written by Python. For example, the URL information in the target database is read by Python.
And S13, extracting the server information in the URL information.
In the present embodiment, the server information in the URL information in the information table is extracted by a regular expression. The server information includes a domain name system host name or an IP address of a server storing the product information. It can be understood that the present solution needs to extract the server information in all the URL information in the above information table.
The regular expression provides a foundation for advanced text pattern matching, search-substitution and other functions. Regular expressions are strings of characters and special symbols that describe some repeating pattern of characters and characters, and thus can match a collection of strings with similar characteristics in some pattern, and thus can match a series of strings with similar characteristics in some pattern.
For example, the regular expression pattern is: 0? [1-9], the matched characters are: any number of bits 1-9 may be preceded by a "0". For example, it may be considered a digital representation of september january, whether in a digital or two-digit representation.
As another example, the regular expression pattern is: \ w @ w +. Com, the matched character is a simple XXX @ YYY.com format email address.
In addition, for example, when the URL information in the information table is: http:// www.baidu.com/ddd/aaa/gggggg.htmla =33% & sid = lV-RgLBX E5wJyFr & r =35d363d1cad5eabfcd131082d275f954#; the data may be represented by a regular expression: ^ (http:// {2 })? ([. Lambda///] +) ([//// [ a-z ] + ]? (/? To extract the server information in the URL information.
It is understood that the protocol and port information in the URL information in the information table may also be extracted through a regular expression, which is not limited herein.
In this embodiment, the step of extracting, by Python, the server information in the URL information using a regular expression includes:
1) Importing a regular expression module through import re;
2) Creating a Regex object through re.composition () function;
3) Using search () or findall () method of Regex object to transfer hostname in URL information to be searched, and returning a Match object;
4) And calling a group () method of the Match object, and returning the matched server information. Thereby extracting server information in the URL information in the information table using a regular expression.
And S14, receiving the input target server information.
The target server information includes new web site information provided by the user for the product in the database. After the testing of the mil-shop subsystem is completed, the website information of the product in the subsystem new database needs to be updated. In this embodiment, target server information input externally may be received through a display unit or an input unit of the electronic device.
And S15, replacing the server information in the URL information with the target server information.
In this embodiment, after replacing the server information in all the URL information extracted from the information table with the target server information, the target server information and the information such as the protocol and the resource file name in the original URL are spliced into a complete URL information. Therefore, the purpose of automatically changing the URL information corresponding to the product information in the information table is achieved.
For example, an oracle database is set to store a table a, where the table a includes a large amount of product information and URL information corresponding to the product. The name of the user logging in the oracle database is load, and the password is 123456.
Then, automatically connecting to the target database is realized through a cx _ Oracle module of the Python, specifically, connecting to the Oracle database through a "conn = cx _ Oracle. Connect ('load/123456 @ localhost/orcl')" statement, acquiring a table a in the Oracle database, and reading the URL information in the table a through a Python technology. And extracting the server information in the URL information in the table A through a regular expression. And after receiving target server information input by a user, replacing the server information in the URL information in the table A with the target server information, and splicing the target server information and information such as a protocol, a resource file name and the like in the original URL into complete URL information.
In summary, the method for automatically configuring the script provided by the present invention automatically connects to a target database through a Python technology, obtains the product URL information in an information table in the target database, automatically extracts a server address in the product URL information according to a regular expression, receives a new server address, and updates the extracted server address to the new server address. Therefore, the product URL information in the information table in the target database is modified in a one-key mode according to the user requirements, and the problem that a large amount of manual resources are occupied due to the fact that the product URL information in the comparison table is manually changed is solved. The software testing time is shortened, and the testing efficiency is improved.
The above description is only a specific embodiment of the present invention, but the scope of the present invention is not limited thereto, and it will be apparent to those skilled in the art that modifications may be made without departing from the inventive concept of the present invention, and these modifications are within the scope of the present invention.
The functional modules and the hardware structure of the electronic device implementing the method for automatically configuring the script are described below with reference to fig. 2 to 3.
Example two
FIG. 2 is a functional block diagram of an apparatus for automatically configuring scripts according to the present invention.
In some embodiments, the apparatus 20 for automating configuration scripts runs in an electronic device. The means 20 for automatically configuring scripts may comprise a plurality of functional modules consisting of program code segments. The program code of the various program segments in the automated configuration scripting apparatus 20 may be stored in a memory and executed by at least one processor to perform (see fig. 1 and its associated description for details) anti-theft functions.
In this embodiment, the apparatus 20 for automatically configuring scripts may be divided into a plurality of function modules according to the functions performed by the apparatus. The functional module may include: a first receiving module 201, a connecting module 202, an extracting module 203, a second receiving module 204 and a processing module 205. The module referred to herein is a series of computer program segments capable of being executed by at least one processor and capable of performing a fixed function and is stored in memory. In some embodiments, the functionality of the modules will be described in greater detail in subsequent embodiments.
The first receiving module 201 is configured to receive input target database information.
Specifically, target database information externally input is received through a display unit or an input unit of the electronic device. The target database information includes an address of the target database, a target database name, and a port. In other embodiments, the target database information further includes a user name and a login password for logging in the database.
The target database can be Sybase, DB2, oracle, SQL server and the like. In this embodiment, the target database is an Oracle database.
The Display unit may be a Liquid Crystal Display (LCD) or an Organic Light-Emitting Diode (OLED) Display. The display unit may be used to display an application program interface. The display unit may also receive the input information, for example, a user may input information in the display unit through an input device such as a finger or a touch pen.
The user can interact with the electronic device through the input unit. For example, information input by a user is received. The user can interact with the electronic equipment through the input unit in a non-contact input mode. Such as motion input, voice input, etc. When the user interacts with the electronic device through voice input, the input unit may be a microphone. The input unit can also be an external remote control unit, and the remote control unit sends a control command to the electronic equipment in a wireless or wired communication mode.
The input unit may also be a mechanical key input unit, such as a key, a stick, a flywheel input key, etc.
In this embodiment, the electronic device may include, but is not limited to, a Personal Computer (PC), a Personal Digital Assistant (PDA), a wireless handheld device, a Tablet Computer (Tablet Computer), a smart phone, and the like.
The connection module 202 is configured to automatically connect to the target database and obtain an information table in the target database, where the information table includes product information and URL information corresponding to the product information.
The Uniform Resource Locator (URL) information is a compact representation of the location and access method of a Resource available from the internet, and is the address of a standard Resource on the internet. Sometimes colloquially referred to as a web address (web site). Each file on the internet has a unique URL.
The base URL consists of three parts: resource type, domain name system host name or IP address of the server storing the resource, and resource file name.
The general syntax format of a URL is:
protocol:// hostname [: port ]/path/[; parameters ] [? query ] # fragment. Wherein, the ones with brackets [ ] are optional.
The protocol is a transport mode/protocol specified for use to tell the browser how to handle the file to be opened. The most common mode is the Hypertext Transfer Protocol (HTTP), other protocols also include file Transfer Protocol ftp, email address mailto, and the like.
The hostname refers to a domain name system host name or IP address of the server where the resource is stored.
The port number (port) is an integer, which is optional. When omitted, a default port is used, and various transport protocols have default port numbers, such as http with a default port number of 80. If the input is omitted, the default port number is used. Sometimes, for security or other reasons, the port may be redefined on the server, i.e. using a non-standard port number, in which case the port number entry cannot be omitted from the URL.
The hostname may also contain the user name and password necessary to log in to the server.
The path includes a path and a file name, and refers to a path to the file and a name of the file itself. The path segments contain hierarchical path definitions, generally with different segments separated by slashes (/).
The parameters are used to specify the options of a particular parameter.
The query portion query is typically used to convey the parameters needed to dynamically query the database on the server.
In this embodiment, the information table describes different URL information corresponding to different products.
For example, when the product is a television, the URL information corresponding to the television is http:// card all. Pingan. Com/lookup product detailinfo. Shtmlpructid =00480787 and keyswords = & shelveid =00480787;
when the product is an oximeter, the URL information corresponding to the oximeter is http:// cardcall. Pingan. Com/lokuppproductDetailInfo. ShtmlProductId =00478872 and keywords = & shelveId =00478872.
In this embodiment, a python technique may be used to implement the connection to the target database. Specifically, the aim of automatically connecting to the target database is achieved through the cx _ Oracle module of the Python.
First, the cx _ Oracle module is downloaded and installed, after which the target database can be connected and used. The process is as follows:
importing a cx _ Oracle module;
connecting a database;
obtaining cursor;
performing various operations by using cursor;
closing the cursor;
the connection is closed.
Wherein the target database is connected by a cx _ oracle.connect (e.g., "username/password @ Oracle server IP/Oracle's SERVICE _ NAME") statement.
For example:
import cx _ Oracle # import cx _ Oracle Module
conn = cx _ oracle. Connect ('load/123456 @ localhost/orcl') # connection database
currsor () c = conn
Execute ('select sysdate from dual') # uses cursor to perform various operations
Fetch () read operation result
close # closed cursor
close () # close linkage
In this embodiment, the target database may also be read and written by Python. For example, the URL information in the target database is read through Python.
The extracting module 203 is configured to extract server information in the URL information.
In the present embodiment, the server information in the URL information in the information table is extracted by a regular expression. The server information includes a domain name system host name or an IP address of a server storing the product information. It can be understood that the present solution needs to extract the server information from all the URL information in the above information table.
The regular expression provides a basis for advanced text pattern matching, search-substitution and other functions. Regular expressions are strings of characters and special symbols that describe some repeating pattern of characters and characters, and thus can match a collection of strings with similar characteristics in some pattern, and thus can match a series of strings with similar characteristics in some pattern.
For example, the regular expression pattern is: 0? [1-9], the matched characters are: any number of bits 1-9 may be preceded by a "0". For example, it may be considered a digital representation of september january, whether in a digital or two-digit representation.
As another example, the regular expression pattern is: \ w @ w +. Com, the matched character is a simple XXX @ YYY.com format email address.
In addition, for example, when the URL information in the information table is: http:// www.baidu.com/ddd/aaa/gggggg. Htmla =33% & sid = lV-RgLBX. E5wJyFr & r =35d363d1cad5eabfcd131082d275f954#; the data may be represented by a regular expression: ^ (http:// {2 })? ([. Lambda///] +) ([//// [ a-z ] + ]? (/? To extract the server information in the URL information.
It is understood that the protocol and port information in the URL information in the information table may also be extracted through a regular expression, which is not limited herein.
In this embodiment, the step of extracting, by Python, the server information in the URL information using a regular expression includes:
1) Importing a regular expression module through import re;
2) Creating a Regex object by a re.component () function;
3) Using search () or findall () method of Regex object to transfer in hostname to be searched, and returning a Match object;
4) And calling a group () method of the Match object, and returning the matched server information. Thereby extracting server information in the URL information in the information table using a regular expression.
The second receiving module 204 is configured to receive input target server information.
The target server information includes new web site information provided by the user for the product in the database. After the testing of the mil-shop subsystem is completed, the website information of the product in the subsystem new database needs to be updated. In the present embodiment, externally input target server information may be received through a display unit or an input unit of the electronic device.
The processing module 205 is configured to replace the server information in the URL information with the target server information.
In this embodiment, after replacing the server information in all the URL information extracted from the information table with the target server information, the target server information and the information such as the protocol and the resource file name in the original URL are spliced into a complete URL information. Therefore, the purpose of automatically changing the URL information corresponding to the product information in the information table is achieved.
For example, an oracle database is configured to store a table a, where the table a includes a large amount of product information and URL information corresponding to the product. The name of the user logging in the oracle database is load, and the password is 123456.
Then, automatically connecting to the target database is realized through a cx _ Oracle module of the Python, specifically, connecting to the Oracle database through a "conn = cx _ Oracle. Connect ('load/123456 @ localhost/orcl')" statement, acquiring a table a in the Oracle database, and reading the URL information in the table a through a Python technology. And extracting the server information in the URL information in the table A through a regular expression. And after receiving target server information input by a user, replacing the server information in the URL information in the table A with the target server information, and splicing the target server information and information such as a protocol, a resource file name and the like in the original URL into complete URL information.
In summary, the apparatus 20 for automatically configuring a script according to the present invention includes a first receiving module 201, a connecting module 202, an extracting module 203, a second receiving module 204, and a processing module 205. The first receiving module 201 is configured to receive input target database information; the connection module 202 is configured to automatically connect to the target database and obtain an information table in the target database, where the information table includes product information and URL information corresponding to the product information; the extracting module 203 is configured to extract server information in the URL information; the second receiving module 204 is configured to receive input target server information; and the processing module 205 is configured to replace the extracted server information in the URL information with the target server information. The device 20 for automatically configuring the script realizes that the product URL information in the information table in the target database is modified by one key according to the user requirement, and solves the problem that a large amount of manual resources are occupied due to the fact that the product URL information in the comparison table is manually changed. The software testing time is shortened, and the testing efficiency is improved.
The integrated unit implemented in the form of a software functional module may be stored in a computer-readable storage medium. The software functional module is stored in a storage medium and includes several instructions to enable a computer device (which may be a personal computer, a dual-screen device, or a network device) or a processor (processor) to execute parts of the methods according to the embodiments of the present invention.
EXAMPLE III
Fig. 3 is a schematic diagram of an electronic device according to a third embodiment of the present invention.
The electronic device 3 includes: a memory 31, at least one processor 32, a computer program 33 stored in the memory 31 and executable on the at least one processor 32, and at least one communication bus 34.
The steps in the above-described embodiments of the automated configuration script method are implemented when the computer program 33 is executed by the at least one processor 32.
Illustratively, the computer program 33 may be partitioned into one or more modules/units, which are stored in the memory 31 and executed by the at least one processor 32 to implement the present invention. The one or more modules/units may be a series of computer program instruction segments capable of performing specific functions, which are used to describe the execution process of the computer program 33 in the electronic device 3.
The electronic device 3 may be a device such as a mobile phone, a tablet computer, a Personal Digital Assistant (PDA) and the like, which is installed with an application program. It will be understood by those skilled in the art that the schematic diagram 3 is merely an example of the electronic device 3, and does not constitute a limitation of the electronic device 3, and may include more or less components than those shown, or combine some components, or different components, for example, the electronic device 3 may further include an input-output device, a network access device, a bus, etc.
The at least one Processor 32 may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic, discrete hardware components, etc. The processor 32 may be a microprocessor or the processor 32 may be any conventional processor or the like, and the processor 32 is a control center of the electronic device 3 and connects various parts of the whole electronic device 3 by various interfaces and lines.
The memory 31 may be used to store the computer program 33 and/or the module/unit, and the processor 32 may implement various functions of the electronic device 3 by running or executing the computer program and/or the module/unit stored in the memory 31 and calling data stored in the memory 31. The memory 31 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application program required by at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area may store data (such as audio data, a phonebook, etc.) created according to the use of the electronic apparatus 3, and the like. In addition, the memory 31 may include a high speed random access memory, and may also include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), at least one magnetic disk storage device, a Flash memory device, or other volatile solid state storage device.
The integrated modules/units of the electronic device 3 may be stored in a computer-readable storage medium if they are implemented in the form of software functional units and sold or used as separate products. Based on such understanding, all or part of the flow of the method according to the embodiments of the present invention may also be implemented by a computer program, which may be stored in a computer-readable storage medium, and which, when executed by a processor, may implement the steps of the above-described embodiments of the method. Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, usb disk, removable hard disk, magnetic disk, optical disk, computer Memory, read-Only Memory (ROM), random Access Memory (RAM), electrical carrier wave signals, telecommunications signals, software distribution medium, and the like. It should be noted that the computer readable medium may contain content that is subject to appropriate increase or decrease as required by legislation and patent practice in jurisdictions, for example, in some jurisdictions, computer readable media does not include electrical carrier signals and telecommunications signals as is required by legislation and patent practice.
In the several embodiments provided in the present invention, it should be understood that the disclosed electronic device and method may be implemented in other manners. For example, the above-described embodiments of the electronic device are merely illustrative, and for example, the division of the units is only one logical functional division, and there may be other divisions when the actual implementation is performed.
In addition, functional units in the embodiments of the present invention may be integrated into the same processing unit, or each unit may exist alone physically, or two or more units are integrated into the same unit. The integrated unit can be realized in a form of hardware, or in a form of hardware plus a software functional module.
It will be evident to those skilled in the art that the invention is not limited to the details of the foregoing illustrative embodiments, and that the present invention may be embodied in other specific forms without departing from the spirit or essential attributes thereof. The present embodiments are therefore to be considered in all respects as illustrative and not restrictive, the scope of the invention being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein. Any reference sign in a claim should not be construed as limiting the claim concerned. Furthermore, it is obvious that the word "comprising" does not exclude other elements or that the singular does not exclude the plural. A plurality of units or means recited in the system claims may also be implemented by one unit or means in software or hardware. The terms first, second, etc. are used to denote names, but not any particular order.
Finally, it should be noted that the above embodiments are only intended to illustrate the technical solutions of the present invention and not to limit the same, and although the present invention is described in detail with reference to the preferred embodiments, it should be understood by those skilled in the art that modifications or equivalent substitutions may be made to the technical solutions of the present invention without departing from the spirit of the technical solutions of the present invention.

Claims (6)

1. A method of automating configuration scripts, the method comprising:
receiving input target database information, wherein the target database information comprises an address of a target database, a name of the target database and a port;
automatically connecting to the target database and obtaining the information table in the target database, including: importing a cx _ Oracle module; connecting the target database according to the address of the target database; acquiring cursor; using cursor to perform corresponding operation, wherein the corresponding operation comprises an operation of reading an information table in the target database; closing the cursor; closing the connection; the information table contains product information and URL information corresponding to the product information, and the URL information comprises: resource type, domain name system host name or IP address of server storing resource and resource file name;
extracting server information in the URL information through a regular expression, wherein the server information comprises: importing a regular expression module through import re; creating a Regex object through re.composition () function; using search () or findall () method of Regex object to transfer the domain name system host name or IP address of the server storing the resource to be searched, and returning a Match object; calling a group () method of the Match object, and returning the matched server information;
receiving input target server information; and
and replacing the server information in the extracted URL information with the target server information.
2. The method of automatically configuring scripts of claim 1, wherein after the step of replacing server information in the extracted URL information with the target server information, the method further comprises:
and splicing the target server information and the resource types and the resource file names in the corresponding URL information in the information table into complete URL information.
3. The method of automatically configuring scripts of claim 1, wherein the target server information includes new web site information provided by a user for a product in the target database.
4. An apparatus for automated configuration of scripts, the apparatus comprising:
the first receiving module is used for receiving input target database information, wherein the target database information comprises an address of a target database, a name of the target database and a port;
the connection module is used for automatically connecting to the target database and acquiring the information table in the target database, and comprises: importing a cx _ Oracle module; connecting the target database according to the address of the target database; acquiring cursor; using cursor to perform corresponding operation, wherein the corresponding operation comprises an operation of reading an information table in the target database; closing the cursor; closing the connection; the information table contains product information and URL information corresponding to the product information, and the URL information comprises: resource type, domain name system host name or IP address of server storing resource and resource file name;
the extraction module is used for extracting the server information in the URL information through a regular expression, and comprises: importing a regular expression module through import re; creating a Regex object by a re.component () function; using search () or findall () method of Regex object to transfer the domain name system host name or IP address of the server storing the resource to be searched, and returning a Match object; calling a group () method of the Match object, and returning the matched server information;
the second receiving module is used for receiving input target server information; and
and the processing module is used for replacing the extracted server information in the URL information with the target server information.
5. An electronic device, comprising a processor and a memory, the processor being configured to implement the method of automated configuration scripting of any one of claims 1 to 3 when executing a computer program stored in the memory.
6. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out a method of automatically configuring a script according to one of claims 1 to 3.
CN201811152520.9A 2018-09-29 2018-09-29 Method and device for automatically configuring script, electronic equipment and storage medium Active CN109542756B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811152520.9A CN109542756B (en) 2018-09-29 2018-09-29 Method and device for automatically configuring script, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811152520.9A CN109542756B (en) 2018-09-29 2018-09-29 Method and device for automatically configuring script, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN109542756A CN109542756A (en) 2019-03-29
CN109542756B true CN109542756B (en) 2023-04-11

Family

ID=65841247

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811152520.9A Active CN109542756B (en) 2018-09-29 2018-09-29 Method and device for automatically configuring script, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN109542756B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113190726A (en) * 2021-04-16 2021-07-30 珠海格力精密模具有限公司 Method for reading CAE (computer aided engineering) modular flow analysis data, electronic equipment and storage medium

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108574604A (en) * 2017-03-07 2018-09-25 北京京东尚科信息技术有限公司 test method and device

Family Cites Families (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102981946B (en) * 2011-09-07 2015-12-16 阿里巴巴集团控股有限公司 ETL smoke test method
US20130067115A1 (en) * 2011-09-12 2013-03-14 Isaac Omar Lapanc Method And System For Mapping Domain Prefixes To Qualified URLs
CN103744802B (en) * 2013-12-20 2017-05-24 北京奇安信科技有限公司 Method and device for identifying SQL injection attacks
CN104363236A (en) * 2014-11-21 2015-02-18 西安邮电大学 Automatic vulnerability validation method
CN105183916A (en) * 2015-10-16 2015-12-23 辽宁工程技术大学 Device and method for managing unstructured data
CN106126688B (en) * 2016-06-29 2020-03-24 厦门趣处网络科技有限公司 Intelligent network information acquisition system and method based on WEB content and structure mining
CN107015804B (en) * 2017-03-29 2020-10-30 武汉大思想信息股份有限公司 Method and system for rapidly developing project by configuring API
CN107766526B (en) * 2017-10-26 2020-04-28 中国人民银行清算总中心 Database access method, device and system

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108574604A (en) * 2017-03-07 2018-09-25 北京京东尚科信息技术有限公司 test method and device

Also Published As

Publication number Publication date
CN109542756A (en) 2019-03-29

Similar Documents

Publication Publication Date Title
US9444899B2 (en) Use of internet information services logging to collect user information in an asynchronous manner
US10216848B2 (en) Method and system for recommending cloud websites based on terminal access statistics
US8108380B2 (en) Inclusion of metadata in indexed composite document
US20110276598A1 (en) System for and method of providing reusable software service information based on natural language queries
US10754628B2 (en) Extracting web API endpoint data from source code to identify potential security threats
CN109829287A (en) Api interface permission access method, equipment, storage medium and device
US20150341771A1 (en) Hotspot aggregation method and device
CN106599017B (en) Scanning analytic method, device and the mobile terminal of installation kit
CN109600385B (en) Access control method and device
CN104765746B (en) Data processing method and device for mobile communication terminal browser
CN102541853A (en) Method and device which are capable of obtaining application information by utilizing browser address bar
CN103313289A (en) Wap system automatic test system and method
CN108055168B (en) Http protocol debugging system, device and method
CN103412944A (en) Internet addressing method and device
CN104065736A (en) URL redirection method, device, and system
CN111047434B (en) Operation record generation method and device, computer equipment and storage medium
CN109542756B (en) Method and device for automatically configuring script, electronic equipment and storage medium
CN115150261A (en) Alarm analysis method and device, electronic equipment and storage medium
CN103678706A (en) Picture recognition method, system, equipment and device based on screenshot information
CN109408471B (en) Compressed packet decompression method and device based on matching tree and storage medium
CN110659165A (en) Multi-node server automatic testing method and device
CN112671878B (en) Block chain information subscription method, device, server and storage medium
CN105516114B (en) Method and device for scanning vulnerability based on webpage hash value and electronic equipment
CN105227599A (en) The recognition methods of Web application and device
CN110737861A (en) webpage data processing method, device, equipment and storage medium

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
GR01 Patent grant
GR01 Patent grant