From ce9b89fe9fb3248aa6009d4ad7693d06e7608329 Mon Sep 17 00:00:00 2001 From: Louis Young <1462648167> Date: Sun, 11 Jul 2021 06:46:36 +0800 Subject: [PATCH] (*):0.1.0 --- LICENSE | 674 +++++++++++++++++++++++ README.md | 125 +++++ Seckill.py | 380 +++++++++++++ WaitingAndBuy.py | 628 +++++++++++++++++++++ __pycache__/Seckill.cpython-38.pyc | Bin 0 -> 10766 bytes __pycache__/WaitingAndBuy.cpython-38.pyc | Bin 0 -> 16021 bytes __pycache__/config.cpython-38.pyc | Bin 0 -> 1340 bytes __pycache__/exception.cpython-38.pyc | Bin 0 -> 495 bytes __pycache__/logger.cpython-38.pyc | Bin 0 -> 825 bytes __pycache__/login.cpython-38.pyc | Bin 0 -> 7545 bytes __pycache__/message.cpython-38.pyc | Bin 0 -> 1528 bytes __pycache__/timer.cpython-38.pyc | Bin 0 -> 2199 bytes __pycache__/util.cpython-38.pyc | Bin 0 -> 7822 bytes config.ini | 47 ++ config.py | 28 + cookies/hniebGKxmYqW.cookies | Bin 0 -> 2718 bytes exception.py | 8 + logger.py | 23 + login.py | 255 +++++++++ main.py | 30 + message.py | 74 +++ timer.py | 66 +++ util.py | 116 ++++ 23 files changed, 2454 insertions(+) create mode 100644 LICENSE create mode 100644 README.md create mode 100644 Seckill.py create mode 100644 WaitingAndBuy.py create mode 100644 __pycache__/Seckill.cpython-38.pyc create mode 100644 __pycache__/WaitingAndBuy.cpython-38.pyc create mode 100644 __pycache__/config.cpython-38.pyc create mode 100644 __pycache__/exception.cpython-38.pyc create mode 100644 __pycache__/logger.cpython-38.pyc create mode 100644 __pycache__/login.cpython-38.pyc create mode 100644 __pycache__/message.cpython-38.pyc create mode 100644 __pycache__/timer.cpython-38.pyc create mode 100644 __pycache__/util.cpython-38.pyc create mode 100644 config.ini create mode 100644 config.py create mode 100644 cookies/hniebGKxmYqW.cookies create mode 100644 exception.py create mode 100644 logger.py create mode 100644 login.py create mode 100644 main.py create mode 100644 message.py create mode 100644 timer.py create mode 100644 util.py diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..f288702 --- /dev/null +++ b/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/README.md b/README.md new file mode 100644 index 0000000..b0e72f5 --- /dev/null +++ b/README.md @@ -0,0 +1,125 @@ +# Jd_Seckill + +## 特别声明: + +* 本仓库发布的`JD_SHOPPER`项目中涉及的任何脚本,仅用于测试和学习研究,禁止用于商业用途,不能保证其合法性,准确性,完整性和有效性,请根据情况自行判断。 + +* 本项目内所有资源文件,禁止任何公众号、自媒体进行任何形式的转载、发布。 + +* `louisyoung1` 对任何脚本问题概不负责,包括但不限于由任何脚本错误导致的任何损失或损害. + +* 间接使用脚本的任何用户,包括但不限于建立VPS或在某些行为违反国家/地区法律或相关法规的情况下进行传播, `louisyoung1` 对于由此引起的任何隐私泄漏或其他后果概不负责。 + +* 请勿将`JD_SHOPPER`项目的任何内容用于商业或非法目的,否则后果自负。 + +* 如果任何单位或个人认为该项目的脚本可能涉嫌侵犯其权利,则应及时通知并提供身份证明,所有权证明,我们将在收到认证文件后删除相关脚本。 + +* 以任何方式查看此项目的人或直接或间接使用`JD_SHOPPER`项目的任何脚本的使用者都应仔细阅读此声明。`louisyoung1` 保留随时更改或补充此免责声明的权利。一旦使用并复制了任何相关脚本或`jd_seckill`项目,则视为您已接受此免责声明。 + +* 您必须在下载后的24小时内从计算机或手机中完全删除以上内容。 + +* 本项目遵循`GPL-3.0 License`协议,如果本特别声明与`GPL-3.0 License`协议有冲突之处,以本特别声明为准。 + +> ***您使用或者复制了本仓库且本人制作的任何代码或项目,则视为`已接受`此声明,请仔细阅读*** +> ***您在本声明未发出之时点使用或者复制了本仓库且本人制作的任何代码或项目且此时还在使用,则视为`已接受`此声明,请仔细阅读*** + +## 简介 +通过我这段时间的使用(2020-12-12至2020-12-17),证实这个脚本确实能抢到茅台。我自己三个账号抢了四瓶,帮两个朋友抢了4瓶。 +大家只要确认自己配置文件没有问题,Cookie没有失效,坚持下去总能成功的。 + +根据这段时间大家的反馈,除了茅台,其它不需要加购物车的商品也不能抢。具体原因还没有进行排查,应该是京东非茅台商品抢购流程发生了变化。 +为了避免耽误大家的时间,先不要抢购非茅台商品。 +等这个问题处理好了,会上线新版本。 + + +## 暗中观察 + +根据12月14日以来抢茅台的日志分析,大胆推断再接再厉返回Json消息中`resultCode`与小白信用的关系。 +这里主要分析出现频率最高的`90016`和`90008`。 + +### 样例JSON +```json +{'errorMessage': '很遗憾没有抢到,再接再厉哦。', 'orderId': 0, 'resultCode': 90016, 'skuId': 0, 'success': False} +{'errorMessage': '很遗憾没有抢到,再接再厉哦。', 'orderId': 0, 'resultCode': 90008, 'skuId': 0, 'success': False} +``` + +### 数据统计 + +| 案例 | 小白信用 | 90016 | 90008 | 抢到耗时 | +| ---- | ---- | ---- | ---- | ---- | +| 张三 | 63.8 | 59.63% | 40.37% | 暂未抢到 | +| 李四 | 92.9 | 72.05% | 27.94% | 4天 | +| 王五 | 99.6 | 75.70% | 24.29% | 暂未抢到 | +| 赵六 | 103.4 | 91.02% | 8.9% | 2天 | + +### 猜测 +推测返回90008是京东的风控机制,代表这次请求直接失败,不参与抢购。 +小白信用越低越容易触发京东的风控。 + +从数据来看小白信用与风控的关系大概每十分为一个等级,所以赵六基本上没有被拦截,李四和王五的拦截几率相近,张三的拦截几率最高。 + +风控放行后才会进行抢购,这时候用的应该是水库计数模型,假设无法一次性拿到所有数据的情况下来尽量的做到抢购成功用户的均匀分布,这样就和概率相关了。 + +> 综上,张三想成功有点困难,小白信用是100+的用户成功几率最大。 + +## 主要功能 + +- 登陆京东商城([www.jd.com](http://www.jd.com/)) + - 用京东APP扫码给出的二维码 +- 预约茅台 + - 定时自动预约 +- 秒杀预约后等待抢购 + - 定时开始自动抢购 + +## 运行环境 + +- [Python 3](https://www.python.org/) + +## 第三方库 + +- 需要使用到的库已经放在requirements.txt,使用pip安装的可以使用指令 +`pip install -r requirements.txt` +- 如果国内安装第三方库比较慢,可以使用以下指令进行清华源加速 +`pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple/` + +## 使用教程 +#### 1. 推荐Chrome浏览器 +#### 2. 网页扫码登录,或者账号密码登录 +#### 3. 填写config.ini配置信息 +(1)`eid`和`fp`找个普通商品随便下单,然后抓包就能看到,这两个值可以填固定的 +> 随便找一个商品下单,然后进入结算页面,打开浏览器的调试窗口,切换到控制台Tab页,在控制台中输入变量`_JdTdudfp`,即可从输出的Json中获取`eid`和`fp`。 +> 不会的话参考原作者的issue https://github.com/zhou-xiaojun/jd_mask/issues/22 + +(2)`sku_id`,`DEFAULT_USER_AGENT` +> `sku_id`已经按照茅台的填好。 +> `cookies_string` 现在已经不需要填写了 +> `DEFAULT_USER_AGENT` 可以用默认的。谷歌浏览器也可以浏览器地址栏中输入about:version 查看`USER_AGENT`替换 + +(3)配置一下时间 +> 现在不强制要求同步最新时间了,程序会自动同步京东时间 +>> 但要是电脑时间快慢了好几个小时,最好还是同步一下吧 + +以上都是必须的. +> tips: +> 在程序开始运行后,会检测本地时间与京东服务器时间,输出的差值为本地时间-京东服务器时间,即-50为本地时间比京东服务器时间慢50ms。 +> 本代码的执行的抢购时间以本地电脑/服务器时间为准 + +(4)修改抢购瓶数 +> 代码中默认抢购瓶数为2,且无法在配置文件中修改 +> 如果一个月内抢购过一瓶,最好修改抢购瓶数为1 +> 具体修改为:在`jd_spider_requests.py`文件中搜索`self.seckill_num = 2`,将`2`改为`1` + +#### 4.运行main.py +根据提示选择相应功能即可 + +#### 5.抢购结果确认 +抢购是否成功通常在程序开始的一分钟内可见分晓! +搜索日志,出现“抢购成功,订单号xxxxx",代表成功抢到了,务必半小时内支付订单!程序暂时不支持自动停止,需要手动STOP! +若两分钟还未抢购成功,基本上就是没抢到!程序暂时不支持自动停止,需要手动STOP! + +## 打赏 +不用再打赏了,抢到茅台的同学请保持这份喜悦,没抢到的继续加油 :) + +## 感谢 +##### 非常感谢原作者 https://github.com/zhou-xiaojun/jd_mask 提供的代码 +##### 也非常感谢 https://github.com/wlwwu/jd_maotai 进行的优化 diff --git a/Seckill.py b/Seckill.py new file mode 100644 index 0000000..6e04e04 --- /dev/null +++ b/Seckill.py @@ -0,0 +1,380 @@ +import random +import time +import functools +from lxml import etree +from logger import logger +from login import SpiderSession, QrLogin +from message import sendMessage +from timer import Timer +from config import global_config +from concurrent.futures import ProcessPoolExecutor +from exception import SKException +from util import ( + parse_json, + wait_some_time, +) + + + + +class Seckiller(object): + def __init__(self): + self.spider_session = SpiderSession() + self.spider_session.load_cookies_from_local() + + self.qrlogin = QrLogin(self.spider_session) + + # 初始化信息 + self.sku_id = global_config.getRaw('config', 'sku_id') + self.seckill_num = eval(global_config.getRaw('settings', 'buy_amount')) + self.seckill_init_info = dict() + self.seckill_url = dict() + self.seckill_order_data = dict() + self.timers = Timer() + + self.session = self.spider_session.get_session() + self.user_agent = self.spider_session.user_agent + self.nick_name = None + + def login_by_qrcode(self): + """ + 二维码登陆 + :return: + """ + if self.qrlogin.is_login: + logger.info('登录成功') + return + + self.qrlogin.login_by_qrcode() + + if self.qrlogin.is_login: + self.nick_name = self.get_username() + self.spider_session.save_cookies_to_local(self.nick_name) + else: + raise SKException("二维码登录失败!") + + def check_login(func): + """ + 用户登陆态校验装饰器。若用户未登陆,则调用扫码登陆 + """ + @functools.wraps(func) + def new_func(self, *args, **kwargs): + if not self.qrlogin.is_login: + logger.info("{0} 需登陆后调用,开始扫码登陆".format(func.__name__)) + self.login_by_qrcode() + return func(self, *args, **kwargs) + return new_func + + @check_login + def reserve(self): + """ + 预约 + """ + self._reserve() + + @check_login + def seckill(self): + """ + 抢购 + """ + self._seckill() + + @check_login + def seckill_by_proc_pool(self): + """ + 多进程进行抢购 + work_count:进程数量 + """ + work_count = eval(global_config.getRaw('settings', 'work_count')) + with ProcessPoolExecutor(work_count) as pool: + for i in range(work_count): + pool.submit(self.seckill) + + def _reserve(self): + """ + 预约 + """ + while True: + try: + self.make_reserve() + break + except Exception as e: + logger.info('预约发生异常!', e) + wait_some_time() + + def _seckill(self): + """ + 抢购 + """ + while True: + try: + self.request_seckill_url() + while True: + self.request_seckill_checkout_page() + self.submit_seckill_order() + except Exception as e: + logger.info('抢购发生异常,稍后继续执行!', e) + wait_some_time() + + + def make_reserve(self): + """商品预约""" + logger.info('商品名称:{}'.format(self.get_sku_title()[:40]+" ......")) + url = 'https://yushou.jd.com/youshouinfo.action?' + payload = { + 'callback': 'fetchJSON', + 'sku': self.sku_id, + '_': str(int(time.time() * 1000)), + } + headers = { + 'User-Agent': self.user_agent, + 'Referer': 'https://item.jd.com/{}.html'.format(self.sku_id), + } + resp = self.session.get(url=url, params=payload, headers=headers) + resp_json = parse_json(resp.text) + reserve_url = resp_json.get('url') + self.timers.start() + while True: + try: + self.session.get(url='https:' + reserve_url) + logger.info('预约成功,已获得抢购资格 / 您已成功预约过了,无需重复预约') + if global_config.getRaw('messenger', 'enable') == 'true': + success_message = "预约成功,已获得抢购资格 / 您已成功预约过了,无需重复预约" + sendMessage(success_message) + break + except Exception as e: + logger.error('预约失败正在重试...') + + def get_username(self): + """获取用户信息""" + url = 'https://passport.jd.com/user/petName/getUserInfoForMiniJd.action' + payload = { + 'callback': 'jQuery{}'.format(random.randint(1000000, 9999999)), + '_': str(int(time.time() * 1000)), + } + headers = { + 'User-Agent': self.user_agent, + 'Referer': 'https://order.jd.com/center/list.action', + } + + resp = self.session.get(url=url, params=payload, headers=headers) + + try_count = 5 + while not resp.text.startswith("jQuery"): + try_count = try_count - 1 + if try_count > 0: + resp = self.session.get(url=url, params=payload, headers=headers) + else: + break + wait_some_time() + # 响应中包含了许多用户信息,现在在其中返回昵称 + # jQuery2381773({"imgUrl":"//storage.360buyimg.com/i.imageUpload/xxx.jpg","lastLoginTime":"","nickName":"xxx","plusStatus":"0","realName":"xxx","userLevel":x,"userScoreVO":{"accountScore":xx,"activityScore":xx,"consumptionScore":xxxxx,"default":false,"financeScore":xxx,"pin":"xxx","riskScore":x,"totalScore":xxxxx}}) + return parse_json(resp.text).get('nickName') + + def get_sku_title(self): + """获取商品名称""" + url = 'https://item.jd.com/{}.html'.format(global_config.getRaw('config', 'sku_id')) + resp = self.session.get(url).content + x_data = etree.HTML(resp) + sku_title = x_data.xpath('/html/head/title/text()') + return sku_title[0] + + def get_seckill_url(self): + """获取商品的抢购链接 + 点击"抢购"按钮后,会有两次302跳转,最后到达订单结算页面 + 这里返回第一次跳转后的页面url,作为商品的抢购链接 + :return: 商品的抢购链接 + """ + url = 'https://itemko.jd.com/itemShowBtn' + payload = { + 'callback': 'jQuery{}'.format(random.randint(1000000, 9999999)), + 'skuId': self.sku_id, + 'from': 'pc', + '_': str(int(time.time() * 1000)), + } + headers = { + 'User-Agent': self.user_agent, + 'Host': 'itemko.jd.com', + 'Referer': 'https://item.jd.com/{}.html'.format(self.sku_id), + } + while True: + resp = self.session.get(url=url, headers=headers, params=payload) + resp_json = parse_json(resp.text) + if resp_json.get('url'): + # https://divide.jd.com/user_routing?skuId=8654289&sn=c3f4ececd8461f0e4d7267e96a91e0e0&from=pc + router_url = 'https:' + resp_json.get('url') + # https://marathon.jd.com/captcha.html?skuId=8654289&sn=c3f4ececd8461f0e4d7267e96a91e0e0&from=pc + seckill_url = router_url.replace( + 'divide', 'marathon').replace( + 'user_routing', 'captcha.html') + logger.info("抢购链接获取成功: %s", seckill_url) + return seckill_url + else: + logger.info("抢购链接获取失败,稍后自动重试") + wait_some_time() + + def request_seckill_url(self): + """访问商品的抢购链接(用于设置cookie等""" + logger.info('用户:{}'.format(self.get_username())) + logger.info('商品名称:{}'.format(self.get_sku_title())) + self.timers.start() + self.seckill_url[self.sku_id] = self.get_seckill_url() + logger.info('访问商品的抢购连接...') + headers = { + 'User-Agent': self.user_agent, + 'Host': 'marathon.jd.com', + 'Referer': 'https://item.jd.com/{}.html'.format(self.sku_id), + } + self.session.get( + url=self.seckill_url.get( + self.sku_id), + headers=headers, + allow_redirects=False) + + def request_seckill_checkout_page(self): + """访问抢购订单结算页面""" + logger.info('访问抢购订单结算页面...') + url = 'https://marathon.jd.com/seckill/seckill.action' + payload = { + 'skuId': self.sku_id, + 'num': self.seckill_num, + 'rid': int(time.time()) + } + headers = { + 'User-Agent': self.user_agent, + 'Host': 'marathon.jd.com', + 'Referer': 'https://item.jd.com/{}.html'.format(self.sku_id), + } + self.session.get(url=url, params=payload, headers=headers, allow_redirects=False) + + def _get_seckill_init_info(self): + """获取秒杀初始化信息(包括:地址,发票,token) + :return: 初始化信息组成的dict + """ + logger.info('获取秒杀初始化信息...') + url = 'https://marathon.jd.com/seckillnew/orderService/pc/init.action' + data = { + 'sku': self.sku_id, + 'num': self.seckill_num, + 'isModifyAddress': 'false', + } + headers = { + 'User-Agent': self.user_agent, + 'Host': 'marathon.jd.com', + } + resp = self.session.post(url=url, data=data, headers=headers) + + resp_json = None + try: + resp_json = parse_json(resp.text) + except Exception: + raise SKException('抢购失败,返回信息:{}'.format(resp.text)) + + return resp_json + + def _get_seckill_order_data(self): + """生成提交抢购订单所需的请求体参数 + :return: 请求体参数组成的dict + """ + logger.info('生成提交抢购订单所需参数...') + # 获取用户秒杀初始化信息 + self.seckill_init_info[self.sku_id] = self._get_seckill_init_info() + init_info = self.seckill_init_info.get(self.sku_id) + default_address = init_info['addressList'][0] # 默认地址dict + invoice_info = init_info.get('invoiceInfo', {}) # 默认发票信息dict, 有可能不返回 + token = init_info['token'] + data = { + 'skuId': self.sku_id, + 'num': self.seckill_num, + 'addressId': default_address['id'], + 'yuShou': 'true', + 'isModifyAddress': 'false', + 'name': default_address['name'], + 'provinceId': default_address['provinceId'], + 'cityId': default_address['cityId'], + 'countyId': default_address['countyId'], + 'townId': default_address['townId'], + 'addressDetail': default_address['addressDetail'], + 'mobile': default_address['mobile'], + 'mobileKey': default_address['mobileKey'], + 'email': default_address.get('email', ''), + 'postCode': '', + 'invoiceTitle': invoice_info.get('invoiceTitle', -1), + 'invoiceCompanyName': '', + 'invoiceContent': invoice_info.get('invoiceContentType', 1), + 'invoiceTaxpayerNO': '', + 'invoiceEmail': '', + 'invoicePhone': invoice_info.get('invoicePhone', ''), + 'invoicePhoneKey': invoice_info.get('invoicePhoneKey', ''), + 'invoice': 'true' if invoice_info else 'false', + 'password': global_config.get('account', 'payment_pwd'), + 'codTimeType': 3, + 'paymentType': 4, + 'areaCode': '', + 'overseas': 0, + 'phone': '', + 'eid': global_config.getRaw('config', 'eid'), + 'fp': global_config.getRaw('config', 'fp'), + 'token': token, + 'pru': '' + } + + return data + + def submit_seckill_order(self): + """提交抢购(秒杀)订单 + :return: 抢购结果 True/False + """ + url = 'https://marathon.jd.com/seckillnew/orderService/pc/submitOrder.action' + payload = { + 'skuId': self.sku_id, + } + try: + self.seckill_order_data[self.sku_id] = self._get_seckill_order_data() + except Exception as e: + logger.info('抢购失败,无法获取生成订单的基本信息,接口返回:【{}】'.format(str(e))) + return False + + logger.info('提交抢购订单...') + headers = { + 'User-Agent': self.user_agent, + 'Host': 'marathon.jd.com', + 'Referer': 'https://marathon.jd.com/seckill/seckill.action?skuId={0}&num={1}&rid={2}'.format( + self.sku_id, self.seckill_num, int(time.time())), + } + resp = self.session.post( + url=url, + params=payload, + data=self.seckill_order_data.get( + self.sku_id), + headers=headers) + resp_json = None + try: + resp_json = parse_json(resp.text) + except Exception as e: + logger.info('抢购失败,返回信息:{}'.format(resp.text[0: 128])) + return False + # 返回信息 + # 抢购失败: + # {'errorMessage': '很遗憾没有抢到,再接再厉哦。', 'orderId': 0, 'resultCode': 60074, 'skuId': 0, 'success': False} + # {'errorMessage': '抱歉,您提交过快,请稍后再提交订单!', 'orderId': 0, 'resultCode': 60017, 'skuId': 0, 'success': False} + # {'errorMessage': '系统正在开小差,请重试~~', 'orderId': 0, 'resultCode': 90013, 'skuId': 0, 'success': False} + # 抢购成功: + # {"appUrl":"xxxxx","orderId":820227xxxxx,"pcUrl":"xxxxx","resultCode":0,"skuId":0,"success":true,"totalMoney":"xxxxx"} + if resp_json.get('success'): + order_id = resp_json.get('orderId') + total_money = resp_json.get('totalMoney') + pay_url = 'https:' + resp_json.get('pcUrl') + logger.info('抢购成功,订单号:{}, 总价:{}, 电脑端付款链接:{}'.format(order_id, total_money, pay_url)) + if global_config.getRaw('messenger', 'enable') == 'true': + success_message = "抢购成功,订单号:{}, 总价:{}, 电脑端付款链接:{}".format(order_id, total_money, pay_url) + sendMessage(success_message) + return True + else: + logger.info('抢购失败,返回信息:{}'.format(resp_json)) + if global_config.getRaw('messenger', 'enable') == 'true': + error_message = '抢购失败,返回信息:{}'.format(resp_json) + sendMessage(error_message) + return False + + diff --git a/WaitingAndBuy.py b/WaitingAndBuy.py new file mode 100644 index 0000000..f586db5 --- /dev/null +++ b/WaitingAndBuy.py @@ -0,0 +1,628 @@ +import math +import functools +from lxml import html + +import requests +import time +import json +import random +from selenium import webdriver +from selenium.webdriver.chrome.options import Options +from concurrent.futures import ProcessPoolExecutor +from exception import SKException +from bs4 import BeautifulSoup +from config import global_config +from logger import logger +from login import SpiderSession, QrLogin +from message import sendMessage + + +class Waiter(): + def __init__(self): + self.spider_session = SpiderSession() + self.spider_session.load_cookies_from_local() + self.session = self.spider_session.get_session() + self.qrlogin = QrLogin(self.spider_session) + self.skuids = global_config.getRaw("config", "sku_id") + self.area = global_config.getRaw("config", "area") + self.eid = global_config.getRaw("config", "eid") + self.fp = global_config.getRaw("config", "fp") + self.user_agent = self.spider_session.user_agent + + def login_by_qrcode(self): + """ + 二维码登陆 + :return: + """ + if self.qrlogin.is_login: + logger.info('登录成功') + return + + self.qrlogin.login_by_qrcode() + + if self.qrlogin.is_login: + self.nick_name = self.getUsername() + self.spider_session.save_cookies_to_local(self.nick_name) + else: + raise SKException("二维码登录失败!") + + def check_login(func): + """ + 用户登陆态校验装饰器。若用户未登陆,则调用扫码登陆 + """ + @functools.wraps(func) + def new_func(self, *args, **kwargs): + if not self.qrlogin.is_login: + logger.info("{0} 需登陆后调用,开始扫码登陆".format(func.__name__)) + self.login_by_qrcode() + return func(self, *args, **kwargs) + return new_func + + def waitForSell(self): + self._waitForSell() + + def get_tag_value(self, tag, key='', index=0): + if key: + value = tag[index].get(key) + else: + value = tag[index].text + return value.strip(' \t\r\n') + + def response_status(self, resp): + if resp.status_code != requests.codes.OK: + print('Status: %u, Url: %s' % (resp.status_code, resp.url)) + return False + return True + + def getUsername(self): + userName_Url = 'https://passport.jd.com/new/helloService.ashx?callback=jQuery339448&_=' + str( + int(time.time() * 1000)) + self.session.headers = { + "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/531.36", + "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3", + "Referer": "https://order.jd.com/center/list.action", + "Connection": "keep-alive" + } + resp = self.session.get(url=userName_Url, allow_redirects=True) + resultText = resp.text + resultText = resultText.replace('jQuery339448(', '') + resultText = resultText.replace(')', '') + usernameJson = json.loads(resultText) + logger.info('登录账号名称' + usernameJson['nick']) + return usernameJson['nick'] + + def get_sku_title(self): + """获取商品名称""" + url = 'https://item.jd.com/{}.html'.format(global_config.getRaw('config', 'sku_id')) + resp = self.session.get(url).content + x_data = html.etree.HTML(resp) + sku_title = x_data.xpath('/html/head/title/text()') + return sku_title[0] + + @check_login + def waitAndBuy_by_proc_pool(self): + """ + 多进程进行抢购 + work_count:进程数量 + """ + work_count = eval(global_config.getRaw('settings', 'work_count')) + with ProcessPoolExecutor(work_count) as pool: + for i in range(work_count): + pool.submit(self.buy) + + + ''' + 检查是否有货 + ''' + + + def check_item_stock(self): + stockurl = 'http://c0.3.cn/stock?skuId=' + self.skuids + '&cat=652,829,854&area=' + self.area + '&extraParam={%22originid%22:%221%22}' + response = self.session.get(stockurl) + resp = self.session.get(stockurl) + jsparser = json.loads(resp.text) + # 33 有货 34 无货 + if jsparser['StockState'] == 33 and jsparser['StockStateName'] == '现货': + print('库存状态:', jsparser['StockStateName']) + return True + else: + print('库存状态:{}(无现货)'.format(jsparser['StockStateName'])) + return False + + def _waitForSell(self): + self.getInfo_selenium() + + def getInfo_selenium(self): + """ + 等待进行抢购 + """ + config_headless = True + + chrome_options = Options() + chrome_options.add_argument(self.user_agent) + chrome_options.add_argument("--profile-directory=Default") + chrome_options.add_argument("--whitelisted-ips") + chrome_options.add_argument("--start-maximized") + chrome_options.add_argument("--disable-extensions") + chrome_options.add_argument("--disable-plugins-discovery") + + if config_headless == True: + # 此处开启后为无头浏览器 + chrome_options.add_argument('--headless') + chrome_options.add_argument('--no-sandbox') + chrome_options.add_argument('--disable-dev-shm-usage') + chrome_options.add_argument('blink-settings=imagesEnabled=false') + chrome_options.add_argument('--disable-gpu') + + logger.info("正在等待商品上架:{}".format(self.get_sku_title()[:40] + " ......")) + driver = webdriver.Chrome('/usr/local/bin/chromedriver', options=chrome_options) + driver.maximize_window() + + while True: + state = False + url = 'https://item.jd.com/{}.html'.format(global_config.getRaw('config', 'sku_id')) + driver.get(url) + time.sleep(5) + buttonValue = driver.find_element_by_xpath( + "/html/body/div[@class='w']/div[@class='product-intro clearfix']/div[@class='itemInfo-wrap']/div[@class='summary p-choose-wrap']/div[@id='choose-btns']/a[@id='InitCartUrl']").get_attribute( + "class") + # joinCart = x_data.xpath("/html/body/div[@class='w']/div[@class='product-intro clearfix']/div[@class='itemInfo-wrap']/div[@class='summary p-choose-wrap']/div[@id='choose-btns']/a[@id='InitCartUrl']/@class") + # notice = x_data.xpath("/html/body/div[@class='w']/div[@class='product-intro clearfix']/div[@class='itemInfo-wrap']/div[@class='summary p-choose-wrap']/div[@id='choose-btns']/a[@id='btn-notify']/text()") + if buttonValue == "btn-special1 btn-lg btn-disable": # 没货 + State = False + else: + state = True + if state: + driver.quit() + sendMessage("商品上架: {}".format(self.get_sku_title()[:40] + " ......")) + logger.info("商品上架: {}".format(self.get_sku_title()[:40] + " ......")) + # self.seckill_by_proc_pool() + self.waitAndBuy_by_proc_pool() + else: + pass + + + + ''' + 取消勾选购物车中的所有商品 + ''' + + + def cancel_select_all_cart_item(self): + url = "https://cart.jd.com/cancelAllItem.action" + data = { + 't': 0, + 'outSkus': '', + 'random': random.random() + } + resp = self.session.post(url, data=data) + if resp.status_code != requests.codes.OK: + print('Status: %u, Url: %s' % (resp.status_code, resp.url)) + return False + return True + + ''' + 勾选购物车中的所有商品 + ''' + + + def select_all_cart_item(self): + url = "https://cart.jd.com/selectAllItem.action" + data = { + 't': 0, + 'outSkus': '', + 'random': random.random() + } + resp = self.session.post(url, data=data) + if resp.status_code != requests.codes.OK: + print('Status: %u, Url: %s' % (resp.status_code, resp.url)) + return False + return True + + + ''' + 删除购物车选中商品 + ''' + + + def remove_item(self): + url = "https://cart.jd.com/batchRemoveSkusFromCart.action" + data = { + 't': 0, + 'null': '', + 'outSkus': '', + 'random': random.random(), + 'locationId': '19-1607-4773-0' + } + headers = { + "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.25 Safari/537.36 Core/1.70.37", + "Accept": "application/json, text/javascript, */*; q=0.01", + "Referer": "https://cart.jd.com/cart.action", + "Host": "cart.jd.com", + "Content-Type": "application/x-www-form-urlencoded", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Encoding": "zh-CN,zh;q=0.9,ja;q=0.8", + "Origin": "https://cart.jd.com", + "Connection": "keep-alive" + } + resp = self.session.post(url, data=data, headers=headers) + logger.info('清空购物车') + if resp.status_code != requests.codes.OK: + print('Status: %u, Url: %s' % (resp.status_code, resp.url)) + return False + return True + + ''' + 购物车详情 + ''' + + + def cart_detail(self): + url = 'https://cart.jd.com/cart.action' + headers = { + "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/531.36", + "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3", + "Referer": "https://order.jd.com/center/list.action", + "Host": "cart.jd.com", + "Connection": "keep-alive" + } + resp = self.session.get(url, headers=headers) + soup = BeautifulSoup(resp.text, "html.parser") + + cart_detail = dict() + for item in soup.find_all(class_='item-item'): + try: + sku_id = item['skuid'] # 商品id + except Exception as e: + logger.info('购物车中有套装商品,跳过') + continue + try: + # 例如:['increment', '8888', '100001071956', '1', '13', '0', '50067652554'] + # ['increment', '8888', '100002404322', '2', '1', '0'] + item_attr_list = item.find(class_='increment')['id'].split('_') + p_type = item_attr_list[4] + promo_id = target_id = item_attr_list[-1] if len(item_attr_list) == 7 else 0 + + cart_detail[sku_id] = { + 'name': self.get_tag_value(item.select('div.p-name a')), # 商品名称 + 'verder_id': item['venderid'], # 商家id + 'count': int(item['num']), # 数量 + 'unit_price': self.get_tag_value(item.select('div.p-price strong'))[1:], # 单价 + 'total_price': self.get_tag_value(item.select('div.p-sum strong'))[1:], # 总价 + 'is_selected': 'item-selected' in item['class'], # 商品是否被勾选 + 'p_type': p_type, + 'target_id': target_id, + 'promo_id': promo_id + } + except Exception as e: + logger.error("商品%s在购物车中的信息无法解析,报错信息: %s,该商品自动忽略", sku_id, e) + + logger.info('购物车信息:%s', cart_detail) + return cart_detail + + + ''' + 修改购物车商品的数量 + ''' + + + def change_item_num_in_cart(self, sku_id, vender_id, num, p_type, target_id, promo_id): + url = "https://cart.jd.com/changeNum.action" + data = { + 't': 0, + 'venderId': vender_id, + 'pid': sku_id, + 'pcount': num, + 'ptype': p_type, + 'targetId': target_id, + 'promoID': promo_id, + 'outSkus': '', + 'random': random.random(), + # 'locationId' + } + self.session.headers = { + "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/531.36", + "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3", + "Referer": "https://cart.jd.com/cart", + "Connection": "keep-alive" + } + resp = self.session.post(url, data=data) + return json.loads(resp.text)['sortedWebCartResult']['achieveSevenState'] == 2 + + + ''' + 添加商品到购物车 + ''' + + + def add_item_to_cart(self, sku_id): + url = 'https://cart.jd.com/gate.action' + payload = { + 'pid': sku_id, + 'pcount': 1, + 'ptype': 1, + } + resp = self.session.get(url=url, params=payload) + if 'https://cart.jd.com/cart.action' in resp.url: # 套装商品加入购物车后直接跳转到购物车页面 + result = True + else: # 普通商品成功加入购物车后会跳转到提示 "商品已成功加入购物车!" 页面 + soup = BeautifulSoup(resp.text, "html.parser") + result = bool(soup.select('h3.ftx-02')) # [

商品已成功加入购物车!

] + + if result: + logger.info('%s 已成功加入购物车', sku_id) + else: + logger.error('%s 添加到购物车失败', sku_id) + + + def get_checkout_page_detail(self): + """获取订单结算页面信息 + + 该方法会返回订单结算页面的详细信息:商品名称、价格、数量、库存状态等。 + + :return: 结算信息 dict + """ + url = 'http://trade.jd.com/shopping/order/getOrderInfo.action' + # url = 'https://cart.jd.com/gotoOrder.action' + payload = { + 'rid': str(int(time.time() * 1000)), + } + headers = { + "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/531.36", + "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3", + "Referer": "https://cart.jd.com/cart.action", + "Connection": "keep-alive", + 'Host': 'trade.jd.com', + } + try: + resp = self.session.get(url=url, params=payload, headers=headers) + if not self.response_status(resp): + logger.error('获取订单结算页信息失败') + return '' + + soup = BeautifulSoup(resp.text, "html.parser") + risk_control = self.get_tag_value(soup.select('input#riskControl'), 'value') + + order_detail = { + 'address': soup.find('span', id='sendAddr').text[5:], # remove '寄送至: ' from the begin + 'receiver': soup.find('span', id='sendMobile').text[4:], # remove '收件人:' from the begin + 'total_price': soup.find('span', id='sumPayPriceId').text[1:], # remove '¥' from the begin + 'items': [] + } + + logger.info("下单信息:%s", order_detail) + return order_detail + except requests.exceptions.RequestException as e: + logger.error('订单结算页面获取异常:%s' % e) + except Exception as e: + logger.error('下单页面数据解析异常:%s', e) + return risk_control + + + def submit_order(self, risk_control): + """提交订单 + + 重要: + 1.该方法只适用于普通商品的提交订单(即可以加入购物车,然后结算提交订单的商品) + 2.提交订单时,会对购物车中勾选✓的商品进行结算(如果勾选了多个商品,将会提交成一个订单) + + :return: True/False 订单提交结果 + """ + url = 'https://trade.jd.com/shopping/order/submitOrder.action' + # js function of submit order is included in https://trade.jd.com/shopping/misc/js/order.js?r=2018070403091 + + # overseaPurchaseCookies: + # vendorRemarks: [] + # submitOrderParam.sopNotPutInvoice: false + # submitOrderParam.trackID: TestTrackId + # submitOrderParam.ignorePriceChange: 0 + # submitOrderParam.btSupport: 0 + # riskControl: + # submitOrderParam.isBestCoupon: 1 + # submitOrderParam.jxj: 1 + # submitOrderParam.trackId: + + data = { + 'overseaPurchaseCookies': '', + 'vendorRemarks': '[]', + 'submitOrderParam.sopNotPutInvoice': 'false', + 'submitOrderParam.trackID': 'TestTrackId', + 'submitOrderParam.ignorePriceChange': '0', + 'submitOrderParam.btSupport': '0', + 'riskControl': risk_control, + 'submitOrderParam.isBestCoupon': 1, + 'submitOrderParam.jxj': 1, + 'submitOrderParam.trackId': '9643cbd55bbbe103eef18a213e069eb0', # Todo: need to get trackId + # 'submitOrderParam.eid': eid, + # 'submitOrderParam.fp': fp, + 'submitOrderParam.needCheck': 1, + } + + def encrypt_payment_pwd(payment_pwd): + return ''.join(['u3' + x for x in payment_pwd]) + self.payment_pwd="0" + if len(self.payment_pwd) > 0: + data['submitOrderParam.payPassword'] = encrypt_payment_pwd(self.payment_pwd) + + headers = { + "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/531.36", + "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3", + "Referer": "http://trade.jd.com/shopping/order/getOrderInfo.action", + "Connection": "keep-alive", + 'Host': 'trade.jd.com', + } + + try: + resp = self.session.post(url=url, data=data, headers=headers) + resp_json = json.loads(resp.text) + + # 返回信息示例: + # 下单失败 + # {'overSea': False, 'orderXml': None, 'cartXml': None, 'noStockSkuIds': '', 'reqInfo': None, 'hasJxj': False, 'addedServiceList': None, 'sign': None, 'pin': 'xxx', 'needCheckCode': False, 'success': False, 'resultCode': 60123, 'orderId': 0, 'submitSkuNum': 0, 'deductMoneyFlag': 0, 'goJumpOrderCenter': False, 'payInfo': None, 'scaleSkuInfoListVO': None, 'purchaseSkuInfoListVO': None, 'noSupportHomeServiceSkuList': None, 'msgMobile': None, 'addressVO': None, 'msgUuid': None, 'message': '请输入支付密码!'} + # {'overSea': False, 'cartXml': None, 'noStockSkuIds': '', 'reqInfo': None, 'hasJxj': False, 'addedServiceList': None, 'orderXml': None, 'sign': None, 'pin': 'xxx', 'needCheckCode': False, 'success': False, 'resultCode': 60017, 'orderId': 0, 'submitSkuNum': 0, 'deductMoneyFlag': 0, 'goJumpOrderCenter': False, 'payInfo': None, 'scaleSkuInfoListVO': None, 'purchaseSkuInfoListVO': None, 'noSupportHomeServiceSkuList': None, 'msgMobile': None, 'addressVO': None, 'msgUuid': None, 'message': '您多次提交过快,请稍后再试'} + # {'overSea': False, 'orderXml': None, 'cartXml': None, 'noStockSkuIds': '', 'reqInfo': None, 'hasJxj': False, 'addedServiceList': None, 'sign': None, 'pin': 'xxx', 'needCheckCode': False, 'success': False, 'resultCode': 60077, 'orderId': 0, 'submitSkuNum': 0, 'deductMoneyFlag': 0, 'goJumpOrderCenter': False, 'payInfo': None, 'scaleSkuInfoListVO': None, 'purchaseSkuInfoListVO': None, 'noSupportHomeServiceSkuList': None, 'msgMobile': None, 'addressVO': None, 'msgUuid': None, 'message': '获取用户订单信息失败'} + # {"cartXml":null,"noStockSkuIds":"xxx","reqInfo":null,"hasJxj":false,"addedServiceList":null,"overSea":false,"orderXml":null,"sign":null,"pin":"xxx","needCheckCode":false,"success":false,"resultCode":600157,"orderId":0,"submitSkuNum":0,"deductMoneyFlag":0,"goJumpOrderCenter":false,"payInfo":null,"scaleSkuInfoListVO":null,"purchaseSkuInfoListVO":null,"noSupportHomeServiceSkuList":null,"msgMobile":null,"addressVO":{"pin":"xxx","areaName":"","provinceId":xx,"cityId":xx,"countyId":xx,"townId":xx,"paymentId":0,"selected":false,"addressDetail":"xx","mobile":"xx","idCard":"","phone":null,"email":null,"selfPickMobile":null,"selfPickPhone":null,"provinceName":null,"cityName":null,"countyName":null,"townName":null,"giftSenderConsigneeName":null,"giftSenderConsigneeMobile":null,"gcLat":0.0,"gcLng":0.0,"coord_type":0,"longitude":0.0,"latitude":0.0,"selfPickOptimize":0,"consigneeId":0,"selectedAddressType":0,"siteType":0,"helpMessage":null,"tipInfo":null,"cabinetAvailable":true,"limitKeyword":0,"specialRemark":null,"siteProvinceId":0,"siteCityId":0,"siteCountyId":0,"siteTownId":0,"skuSupported":false,"addressSupported":0,"isCod":0,"consigneeName":null,"pickVOname":null,"shipmentType":0,"retTag":0,"tagSource":0,"userDefinedTag":null,"newProvinceId":0,"newCityId":0,"newCountyId":0,"newTownId":0,"newProvinceName":null,"newCityName":null,"newCountyName":null,"newTownName":null,"checkLevel":0,"optimizePickID":0,"pickType":0,"dataSign":0,"overseas":0,"areaCode":null,"nameCode":null,"appSelfPickAddress":0,"associatePickId":0,"associateAddressId":0,"appId":null,"encryptText":null,"certNum":null,"used":false,"oldAddress":false,"mapping":false,"addressType":0,"fullAddress":"xxxx","postCode":null,"addressDefault":false,"addressName":null,"selfPickAddressShuntFlag":0,"pickId":0,"pickName":null,"pickVOselected":false,"mapUrl":null,"branchId":0,"canSelected":false,"address":null,"name":"xxx","message":null,"id":0},"msgUuid":null,"message":"xxxxxx商品无货"} + # {'orderXml': None, 'overSea': False, 'noStockSkuIds': 'xxx', 'reqInfo': None, 'hasJxj': False, 'addedServiceList': None, 'cartXml': None, 'sign': None, 'pin': 'xxx', 'needCheckCode': False, 'success': False, 'resultCode': 600158, 'orderId': 0, 'submitSkuNum': 0, 'deductMoneyFlag': 0, 'goJumpOrderCenter': False, 'payInfo': None, 'scaleSkuInfoListVO': None, 'purchaseSkuInfoListVO': None, 'noSupportHomeServiceSkuList': None, 'msgMobile': None, 'addressVO': {'oldAddress': False, 'mapping': False, 'pin': 'xxx', 'areaName': '', 'provinceId': xx, 'cityId': xx, 'countyId': xx, 'townId': xx, 'paymentId': 0, 'selected': False, 'addressDetail': 'xxxx', 'mobile': 'xxxx', 'idCard': '', 'phone': None, 'email': None, 'selfPickMobile': None, 'selfPickPhone': None, 'provinceName': None, 'cityName': None, 'countyName': None, 'townName': None, 'giftSenderConsigneeName': None, 'giftSenderConsigneeMobile': None, 'gcLat': 0.0, 'gcLng': 0.0, 'coord_type': 0, 'longitude': 0.0, 'latitude': 0.0, 'selfPickOptimize': 0, 'consigneeId': 0, 'selectedAddressType': 0, 'newCityName': None, 'newCountyName': None, 'newTownName': None, 'checkLevel': 0, 'optimizePickID': 0, 'pickType': 0, 'dataSign': 0, 'overseas': 0, 'areaCode': None, 'nameCode': None, 'appSelfPickAddress': 0, 'associatePickId': 0, 'associateAddressId': 0, 'appId': None, 'encryptText': None, 'certNum': None, 'addressType': 0, 'fullAddress': 'xxxx', 'postCode': None, 'addressDefault': False, 'addressName': None, 'selfPickAddressShuntFlag': 0, 'pickId': 0, 'pickName': None, 'pickVOselected': False, 'mapUrl': None, 'branchId': 0, 'canSelected': False, 'siteType': 0, 'helpMessage': None, 'tipInfo': None, 'cabinetAvailable': True, 'limitKeyword': 0, 'specialRemark': None, 'siteProvinceId': 0, 'siteCityId': 0, 'siteCountyId': 0, 'siteTownId': 0, 'skuSupported': False, 'addressSupported': 0, 'isCod': 0, 'consigneeName': None, 'pickVOname': None, 'shipmentType': 0, 'retTag': 0, 'tagSource': 0, 'userDefinedTag': None, 'newProvinceId': 0, 'newCityId': 0, 'newCountyId': 0, 'newTownId': 0, 'newProvinceName': None, 'used': False, 'address': None, 'name': 'xx', 'message': None, 'id': 0}, 'msgUuid': None, 'message': 'xxxxxx商品无货'} + # 下单成功 + # {'overSea': False, 'orderXml': None, 'cartXml': None, 'noStockSkuIds': '', 'reqInfo': None, 'hasJxj': False, 'addedServiceList': None, 'sign': None, 'pin': 'xxx', 'needCheckCode': False, 'success': True, 'resultCode': 0, 'orderId': 8740xxxxx, 'submitSkuNum': 1, 'deductMoneyFlag': 0, 'goJumpOrderCenter': False, 'payInfo': None, 'scaleSkuInfoListVO': None, 'purchaseSkuInfoListVO': None, 'noSupportHomeServiceSkuList': None, 'msgMobile': None, 'addressVO': None, 'msgUuid': None, 'message': None} + + if resp_json.get('success'): + logger.info('订单提交成功! 订单号:%s', resp_json.get('orderId')) + sendMessage('订单提交成功! 订单号:{}'.format(resp_json.get('orderId'))) + return True + else: + message, result_code = resp_json.get('message'), resp_json.get('resultCode') + if result_code == 0: + # self._save_invoice() + message = message + '(下单商品可能为第三方商品,将切换为普通发票进行尝试)' + elif result_code == 60077: + message = message + '(可能是购物车为空 或 未勾选购物车中商品)' + elif result_code == 60123: + message = message + '(需要在payment_pwd参数配置支付密码)' + logger.info('订单提交失败, 错误码:%s, 返回信息:%s', result_code, message) + logger.info(resp_json) + return False + except Exception as e: + logger.error(e) + return False + + + + + + ''' + 购买环节 + 测试三次 + ''' + + + def buyMask(self, sku_id): + retry = eval(global_config.getRaw("config", "retry")) + for count in range(retry): + logger.info('第[%s/%s]次尝试提交订单', count, 3) + self.cancel_select_all_cart_item() + cart = self.cart_detail() + if sku_id in cart: + logger.info('%s 已在购物车中,调整数量为 %s', sku_id, 1) + cart_item = cart.get(sku_id) + self.change_item_num_in_cart( + sku_id=sku_id, + vender_id=cart_item.get('vender_id'), + num=1, + p_type=cart_item.get('p_type'), + target_id=cart_item.get('target_id'), + promo_id=cart_item.get('promo_id') + ) + else: + self.add_item_to_cart(sku_id) + risk_control = self.get_checkout_page_detail() + if risk_control == '刷新太频繁了': + return False + if len(risk_control) > 0: + if self.submit_order(risk_control): + return True + logger.info('休息%ss', 3) + time.sleep(3) + else: + logger.info('执行结束,提交订单失败!') + return False + + + ''' + 查询库存 + ''' + + ''' + update by rlacat + 解决skuid长度过长(超过99个)导致无法查询问题 + ''' + def check_stock(self): + st_tmp = [] + len_arg = 70 + #print("skustr:",skuidStr) + #print("skuids:",len(skuids)) + skuid_nums = len(self.skuids) + skuid_batchs = math.ceil(skuid_nums / len_arg) + #print("skuid_batchs:",skuid_batchs) + if(skuid_batchs > 1): + for i in range(0,skuid_batchs): + if(len_arg*(i+1) <= len(self.skuids)): + #print("取个数:",len_arg*i,"至",len_arg*(i+1)) + skuidStr = ','.join(self.skuids[len_arg*i:len_arg*(i+1)]) + st_tmp+=self.check_stock_tmp(skuidStr,self.skuids[len_arg*i:len_arg*(i+1)]) + else: + #print("取个数:",len_arg*i,"至",len_arg*(i+1)) + skuidStr = ','.join(self.skuids[len_arg*i:skuid_nums])#skuid配置的最后一段 + #print(skuidStr) + st_tmp+=self.check_stock_tmp(skuidStr,self.skuids[len_arg*i:skuid_nums]) + else: + #<=1的情况 + skuidStr = ','.join(self.skuids) + st_tmp=self.check_stock_tmp(skuidStr,self.skuids) + return st_tmp + + def check_stock_tmp(self, skuidString,skuids_a): + callback = 'jQuery' + str(random.randint(1000000, 9999999)) + headers = { + "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/531.36", + "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3", + "Referer": "https://cart.jd.com/cart.action", + "Connection": "keep-alive", + } + url = 'https://c0.3.cn/stocks' + payload = { + 'type': 'getstocks', + 'skuIds': skuidString, + 'area': self.area, + 'callback': callback, + '_': int(time.time() * 1000), + } + resp = self.session.get(url=url, params=payload, headers=headers) + resptext = resp.text.replace(callback + '(', '').replace(')', '') + respjson = json.loads(resptext) + inStockSkuid = [] + nohasSkuid = [] + #print(resptext,respjson) + for i in skuids_a: + #print("当前处理:",i) + if(respjson[i]['StockStateName'] != '无货'): + inStockSkuid.append(i) + else: + nohasSkuid.append(i) + #print(nohasSkuid) + logger.info('[%s]无货', ','.join(nohasSkuid)) + return inStockSkuid + + @check_login + def buy(self): + sku_id = global_config.getRaw('config', 'sku_id') + retry = eval(global_config.getRaw("config", "retry")) + for count in range(retry): + logger.info('第[%s/%s]次尝试提交订单', count, retry) + self.cancel_select_all_cart_item() + cart = self.cart_detail() + if sku_id in cart: + logger.info('%s 已在购物车中,调整数量为 %s', sku_id, 1) + cart_item = cart.get(sku_id) + self.change_item_num_in_cart( + sku_id=sku_id, + vender_id=cart_item.get('vender_id'), + num=1, + p_type=cart_item.get('p_type'), + target_id=cart_item.get('target_id'), + promo_id=cart_item.get('promo_id') + ) + else: + self.add_item_to_cart(sku_id) + risk_control = self.get_checkout_page_detail() + if risk_control == '刷新太频繁了': + return False + if len(risk_control) > 0: + if self.submit_order(risk_control): + return True + logger.info('休息%ss', 3) + time.sleep(3) + else: + logger.info('执行结束,提交订单失败!') + return False + diff --git a/__pycache__/Seckill.cpython-38.pyc b/__pycache__/Seckill.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..63d2443c23e1e6032b3fa3dc44b8c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4%LO`CAWEAoL{JWGJq=X1sM8k2hD&tiAJ|!PJ7R3R$#l#lAoX7=e+Ov^UHCg;S(4?_4TKhHX*-ob9*?jc>_~zf#HPH zgapM(1NxqDi`!R(+rqlE16$aaByc!AA}!|{&XZ1r_VxgdBHu1Jf&`S4z~aj$4-IVY z@X8hDaCsHh3UBfn_pfN+@+Dq}NR>Ar`-*n=v$PxcZv4osJ8>FE)-59RvG#qKstYD3 zeLAsnGO?#*OsCeEFvr9yW72n~RBh!hr`@UU128Zif^&Xm0mr7jGZh$$c8C@CuJsey+}U@r4llz7pfeZovyM1)Q%J( z51Jpt^Ee7}h=`aut-j*=rv|a@7_xj>1r8Y5T4CDw1pA#|NCQ;+&|4d$p>l(kcyi?B<| zf&QPD#E(IFGNEHSwx-q*nbA(mk`0J!8&sRwas~XL3T5PRmTD&r&xE;0Vb%bZ55Y8H zD$_D_Sl*m8eA-rlyTk2e55e2Xu=;JiB_)@6zoKil8eTx=! z_nAO6!?Xcs?lYBG2R=q&VR?d!hfRSm!u;HGK81|5;f;qg4 zSFsX;Vvtx|4?Nehv#Bm!h?wSSg-A<*)n?+_nYLEm>a}nk#KcHz5!di@9F46mZKTUI zk+LlE=)8E$O(B(y?i6OSsAP&(C-M^tJGGbVZG$D+7{oFp?+xv7*I^PwEkb=}=+!gdyR&<>da0qUU0CbF Mlg;6$Z17EhU$B&N`v3p{ literal 0 HcmV?d00001 diff --git a/__pycache__/logger.cpython-38.pyc b/__pycache__/logger.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..dc46d495066df9986c2e83e6a026dd5abc508173 GIT binary patch literal 825 zcmY*X&5ja55bmBohQC$g$&2AK33C9hhHQwsfUIGGEZKu&47Sq^3(gPeZj2B(>2==$ zZu$;B$y`0HkKjeC2XNQ!bX9*Z(}GAz0s@{CfXGL+Gah_ZQgEb2y?3f+C6o zCmkAdO z&KVpr10m5COKqm_u*$N5H#Q0zYqZ8xztJ|D)VAghZS=Liwbq*AK}=?yMgY^EWo3>U z)T9>8+!z~UZT!bG(##0{XZKdkw@#S|Urs~jig%^5Qx0Rg2mn-_@^}&XJ)%5ry>#l7 z1NMmpQEF(EfXRd)6Y#DcId3XXSaE2{>C~Nzx-)dOL?4GT$xtF0T&4(Z(XA?WWiI5n z^32seJ0zc9E+rFQ{sZwpF6L+PB9e*CB0r|nXyWD*3)(ed+_MFfUG;jBQ5J9}#(A&Z z_pe) z-iwQtYjQOKTnFK0$NwIC;Kz}O12#J3@(N=}aYWw{S5x)7QM(e1iyGropAa5LwWcZ} zo-Eai1-7?VXHYj-13+t*y3FOwY9Fxo?vPdo*IZ~+^zPq2-1uq~{ibpNrm9OeaJ zxE9ZV@*W;~RXrBWvtUlL6KH1ISFR>64N3odPvjNRKHU#P0|OH32R6111KYY?{0qt_ B*M0y1 literal 0 HcmV?d00001 diff --git a/__pycache__/login.cpython-38.pyc b/__pycache__/login.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..63c1b98d5d6d3f74f80830cd5c584bee7e4402ca GIT binary patch literal 7545 zcma)BU3479mF~Zp>G{#G|1e>R!X99U7zyIDSz>Tv$F|5WLP9Y>kEi0I9?B*1ZK<|= zd#XL(k?P2IraJRosV-G{USVMtc}-!F87!Ow44{?+Z;PyV@n@%+-gInka`A<_6z-N1DKm-7e;rdAb8an*T^ zmbsweNv|sN#)5(xtcWR%fl92mFHyDzMRFf+$yErQBE-O!XvhOI6djb%8tz~sIuUCZC18Gs+S+)Mf}Qj)iWGBH+)^; zTQKyqy?sY9#_6+pHj_^CVxjM#eZtPc61;D4${iIA!|8I)?fbif*3fre8XP=yxDQy! z7J5rlo@vQxtnKv4VHAoQR@=48_9i{{HpH6LMK+~NsEc0UD)Z`sG7Y88YfzC2WdVfO z)q$kpncSWz+m7q-PDpxje6lrar(r9{i};nK#=FreB*f>*Vk@U+Ro3tJJPEyNPPqwz^bI(rf zeX92xy9Dz4Chg-TznU%;Ms_{X_k`$wrs-WycBEjlC+(A&(R5+Ne)h!P1P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6Ks<#jiG~#(Yk1XIp7^gPg#E5E^gTQ++cS7dZ7m0VBd7lh DKV@ji literal 0 HcmV?d00001 diff --git a/__pycache__/util.cpython-38.pyc b/__pycache__/util.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..63b11dc460591cc685850b7e2d0c53e737af8f34 GIT binary patch literal 7822 zcmcgx-ESOM6`!wNuh$<5N!onTGA(V%w)X7K$Bw;m+9q+50!f?@$2eN48peCZ_Sm~K z>pQb?ytNTki&P<%B7uZdMPT!QK%#&U4+tdq4|qoNO5@b;Jn;aWJ8Re8+3Yquwi$cx zoqO-x`Q3BQ@0|NFQv(BO2Cql3^_}tO80Md}u=i51a1nprKQI9X*fLXW8Ff2A+kJa0*Vt z88{1HhUegU_zH;d0=x)cg_q!Ecm=)&=O6>G!fP-D!yrKxav*~ODrj>`u?O;?zt0p? zFao2P_d)^AW1faFxPW;dybf<*-VblWMa&1_5?sc75ZFm3Gron=F%ua!7?>-&GiKQ+ zxz4OTSBIN!-7c5SY+lNV=ca83++|OkxGUI6lD}&HEGV8#NO^yUv5IVX_joqcfI*B@f(hB zl|`%&Z%vB#L^)^B|G2;-k{kh^YXZI}%VXjV+o?SeAB^gTuEht6O1Rhr)U3xbar)Nu z{|QXpCz#%1yAG0R`vjw$YbHtuu>DHb3f7kU`S{$|BsC(^Y&&MiIVsmQ0kIFdn5;>K zD9%a~&VlE15H8tL~Ph$N~f%evs_o{(oD`5 zaE6F-v;$gP(G*-0AsWUUJvvReO|c-H*~bY+0b3u{MU75jBk06Y-~Xb`-7a9ue9^&j zah17?7L~5;qCLijmF`p}S<_oLtQ}CgUZCutv__J{Kta?EdT* zb+}S%0G_aX+*!pJMQ)icms&w~qr6&>ai5;U>F*#RV>ug6h8>O!m2gR`;%N0IEy^R^ zEVD+Rv}=4SVBBX#abwM9a{h~@R0@$JC^_G0(bGO!%G%R_;W~2fL?CM=mYxA`Up(ds z{Eg$!dli#aW*rZ|H`p~6?^xhASl~}GYn;!m^Q+7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al 0 HcmV?d00001 diff --git a/config.ini b/config.ini new file mode 100644 index 0000000..ed17e19 --- /dev/null +++ b/config.ini @@ -0,0 +1,47 @@ +[config] +model = 3 +# eid, fp参数必须填写,具体请参考 wiki-常见问题 +# 随意填写可能导致订单无法提交等问题 +eid = "2PBCMB2WINZUQI6XRDCSKOZXTCHEOHLDABNAVSAEYTS6DBH2DWOACQPUEKXGHV7ZYTKCRDXZX34SPL2XI3KQYVNVSM" +fp = "63a2c6fceb97a082753cdf00710f4f46", date: 1625908188000, token: "TOIZXRT67BODBKILHE2PAYYL4PNV4WL7DC75LVS6N5FG7ZRWD54JHTO3XFQLPIGTY2HXTM24VURQU", jstub: "BEHLQIWVQ3SRHZCTVLIQE2VZG5GPCS7JRWQME6EFPOETESYXMF…O2EXYEO4UAWOQLZ7QVDOXZ3ZFII7ASKCWX5KEZ6WMXJTCGTCA" +# cookie现在不需要填写了 +# cookies_String = "" +area = 21_1827_4101_40925 +# 商品id +# 已经是xbox的sku_id了 +#sku_id = 100021890778 +sku_id = 7816155 +# 设定时间 # 2020-12-09 10:00:00.100000 +# 修改成每天的几点几分几秒几毫秒 +buy_time = 2021-07-11 09:59:59.500 +# 提交订单失败重试次数 +retry = 50 +# 默认UA +DEFAULT_USER_AGENT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36" +# 是否使用随机 useragent,默认为 false +random_useragent = false + +[settings] +# 购买数量 +buy_amount = 1 +# 多进程数量 +work_count = 6 + +[account] +# 支付密码 +# 如果你的账户中有可用的京券(注意不是东券)或 在上次购买订单中使用了京豆, +# 那么京东可能会在下单时自动选择京券支付 或 自动勾选京豆支付。 +# 此时下单会要求输入六位数字的支付密码。请在下方配置你的支付密码,如 123456 。 +# 如果没有上述情况,下方请留空。 +payment_pwd = "" + +[messenger] +# 使用了Mirai_QQ的推送服务 +enable = false +# model改成group发送到QQ群 +model = user +# model-user模式下填写QQ号 +user_id = 1462648167 +# model-group下填写群号 +group_id = NULL +server_address = www.louisyoung.site:8088 diff --git a/config.py b/config.py new file mode 100644 index 0000000..554f09a --- /dev/null +++ b/config.py @@ -0,0 +1,28 @@ +import os +import configparser + + +class Config(object): + def __init__(self, config_file='config.ini'): + self._path = os.path.join(os.getcwd(), config_file) + if not os.path.exists(self._path): + raise FileNotFoundError("No such file: config.ini") + self._config = configparser.ConfigParser() + self._config.read(self._path, encoding='utf-8-sig') + self._configRaw = configparser.RawConfigParser() + self._configRaw.read(self._path, encoding='utf-8-sig') + + def get(self, section, name): + return self._config.get(section, name) + + def getRaw(self, section, name): + return self._configRaw.get(section, name) + + def setModel(self, model=''): + self.model = model + + def getModel(self): + return self.model + + +global_config = Config() diff --git a/cookies/hniebGKxmYqW.cookies b/cookies/hniebGKxmYqW.cookies new file mode 100644 index 0000000000000000000000000000000000000000..87b2f1ba7173f1261eca23981464a6efda31afe1 GIT binary patch literal 2718 zcmb_e$!^<57=Tm2 zo|9N^*t5NW2A)g;lT20`9HQ7e@a&d9MtD4#4#?%1QMPnGGf7sN$)27E2}&$4@Dk7V zDVpz7Wuxrj<@v}?FpVw|bTy6YL%-c=Dj@0C2kYy3Rv6>t zX7*tGwn&5=>M3%m*!hWD_={}mba-j{;Uso$T|ze%PMpHaG#|C>!iM8){?xp2H=tqU z#kBFvY{B(tkHqdcN|p9dFeYW#OIIw`sp7hq zP^|?s3{aj@Q*T>Ij=wr>WBg5J20z2=cqMzW_uNoxa=8@%+qY|tU5{+^qhMDY9yE?R zX5&psf_q0~$8HXo^&CGp@rw~&&8`#$uZ{4_5oYi*W{)vA#?ZvvG3HGym{=TPiB|0j zFG6|UDWXHqL3Pxhrl(VS%Q6BsFA5Mrnd1b(mJV7B0J05SnRgJ+{x3@9_rL#XV{UYb z*0b!tyh}-TuOF}V&KnRfQ#p6Gwzbej74&wR`4(l)D2lF>N^f>o_rd`aR;#YO-HG-( zua0C8i2ESk-7@wQ4IaL3A*Ng1^3IfC^P-s}3`WM5db0BOdLq6>D?EumPEbJz>hq_MdoKX|69pjhBXXU+)5v}DyBetDx zsW^>hQM7lgAXduwRRga2uO(M)hAiJ~?$oON(g3Uq5F3!KZxGpS^tsaZX0f?BbQ578 zZKgI!(nG#BtZiAE5F|!D+=PN^Y6mUL!@Zu`OwFC`#N8|sXQQG6zhg+@p2PKEoro2l z1&Q(Ib@eFOK9h59)m2&L+g`0R-6B+4A;Dohtqb9m-Q`;|Gm-!_l?AG1NE#xI9*o^ zPNolJHHl)-O&TY2&?u@ZCyVqOsGPzx9Mk|WLQPZ!RR*l2K)?xxRs@E?0$EdJAjouH z2cmAUl%x(=-e4pNNCKy662ohXB(kaq6&(OgP#IR_cwLrhHeC@_9%wQTp{DT)CsH_8 z;Z#XfSw)dpndgg;Wkrz(GAD?@pjs48Q8dP2H61e41%Z=qUEo!*(SKE!0r)Q4qH()m`t1QEmiVzWv)Dt!oNCOVOsWVv6-(;NrkTt&PgCx7Tmp z4CDRZOIOYv+EjCC;5prClp#gA|8X!b9&O{p_O62n_Tb4iI&~R*Pf=$XhPjcTE48Az zXRRcfmhvM_`V?3B2G=u7cqfFlp6V43m8#MH8W!nuBee3r*th71ZF=Db?P=JbDeSEa mSHs!Sc=h*wosxnT(OY%OpI>Osk5>Dsx}+q 10: + mes = mes[:10] + "···" + logger.info("Send {}".format(mes)) + + + # print(sender.request.url) + # sender.raise_for_status() + # print(sender.text) + return True + except: + logger.error("Message Send Failed") + return False + + +def sendGroupMessage(message, groupid): + URL = global_config.getRaw("messenger", "server_address") + path = "sendGroupMessage" + try: + URL = "http://{}/{}".format(URL, path) + + body = { + "sessionKey": "YourSession", + "target": groupid, + "messageChain": [ + {"type": "Plain", "text": message} + ] + } + + # sender = requests.post(URL, params = params, data=json.dumps(body)) + sender = requests.post(URL, data=json.dumps(body)) + mes = message.replace("\n", " ") + if len(mes) > 10: + mes = mes[:10] + "···" + logger.info("Send {}".format(mes)) + + # print(sender.request.url) + # sender.raise_for_status() + # print(sender.text) + return True + except: + logger.error("Message Send Failed") + return False diff --git a/timer.py b/timer.py new file mode 100644 index 0000000..7a42f8d --- /dev/null +++ b/timer.py @@ -0,0 +1,66 @@ +# -*- coding:utf-8 -*- +import time +import requests +import json + +from datetime import datetime +from logger import logger +from config import global_config + + +class Timer(object): + def __init__(self, sleep_interval=0.5): + # '2018-09-28 22:45:50.000' + # buy_time = 2020-12-22 09:59:59.500 + buy_time_everyday = global_config.getRaw('config', 'buy_time').__str__() + localtime = time.localtime(time.time()) + #self.buy_time = datetime.strptime( + # localtime.tm_year.__str__() + '-' + localtime.tm_mon.__str__() + '-' + localtime.tm_mday.__str__() + # + ' ' + buy_time_everyday, + # "%Y-%m-%d %H:%M:%S.%f") + self.buy_time = datetime.strptime(buy_time_everyday, "%Y-%m-%d %H:%M:%S.%f") + self.buy_time_ms = int(time.mktime(self.buy_time.timetuple()) * 1000.0 + self.buy_time.microsecond / 1000) + self.sleep_interval = sleep_interval + + self.diff_time = self.local_jd_time_diff() + + def jd_time(self): + """ + 从京东服务器获取时间毫秒 + :return: + """ + url = 'https://api.m.jd.com/client.action?functionId=queryMaterialProducts&client=wh5' + ret = requests.get(url).text + js = json.loads(ret) + return int(js["currentTime2"]) + # return int(round(time.time() * 1000)) + + def local_time(self): + """ + 获取本地毫秒时间 + :return: + """ + return int(round(time.time() * 1000)) + + def local_jd_time_diff(self): + """ + 计算本地与京东服务器时间差 + :return: + """ + return self.local_time() - self.jd_time() + + def start(self): + logger.info('正在等待到达设定时间:{}'.format(self.buy_time)) + logger.info('正检测本地时间与京东服务器时间误差为【{}】毫秒'.format(self.diff_time)) + model = global_config.getModel() + if model != '3': + while True: + # 本地时间减去与京东的时间差,能够将时间误差提升到0.1秒附近 + # 具体精度依赖获取京东服务器时间的网络时间损耗 + if self.local_time() - self.diff_time >= self.buy_time_ms: + logger.info('时间到达,开始执行……') + break + else: + time.sleep(self.sleep_interval) + else: + pass diff --git a/util.py b/util.py new file mode 100644 index 0000000..fd81f0d --- /dev/null +++ b/util.py @@ -0,0 +1,116 @@ +import json +import random +import requests +import os +import time + +from config import global_config + +USER_AGENTS = [ + "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36", + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2227.1 Safari/537.36", + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2227.0 Safari/537.36", + "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2227.0 Safari/537.36", + "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2226.0 Safari/537.36", + "Mozilla/5.0 (Windows NT 6.4; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2225.0 Safari/537.36", + "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2225.0 Safari/537.36", + "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2224.3 Safari/537.36", + "Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.93 Safari/537.36", + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.124 Safari/537.36", + "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2049.0 Safari/537.36", + "Mozilla/5.0 (Windows NT 4.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2049.0 Safari/537.36", + "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.67 Safari/537.36", + "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.67 Safari/537.36", + "Mozilla/5.0 (X11; OpenBSD i386) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.125 Safari/537.36", + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1944.0 Safari/537.36", + "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.3319.102 Safari/537.36", + "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.2309.372 Safari/537.36", + "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.2117.157 Safari/537.36", + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.47 Safari/537.36", + "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1866.237 Safari/537.36", + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.137 Safari/4E423F", + "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.116 Safari/537.36 Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.10", + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.517 Safari/537.36", + "Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1667.0 Safari/537.36", + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1664.3 Safari/537.36", + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1664.3 Safari/537.36", + "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.16 Safari/537.36", + "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1623.0 Safari/537.36", + "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.17 Safari/537.36", + "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.62 Safari/537.36", + "Mozilla/5.0 (X11; CrOS i686 4319.74.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.57 Safari/537.36", + "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.2 Safari/537.36", + "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1468.0 Safari/537.36", + "Mozilla/5.0 (Windows NT 6.2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1467.0 Safari/537.36", + "Mozilla/5.0 (Windows NT 6.2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1464.0 Safari/537.36", + "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1500.55 Safari/537.36", + "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.93 Safari/537.36", + "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.93 Safari/537.36", + "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.93 Safari/537.36", + "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.93 Safari/537.36", + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.93 Safari/537.36", + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.93 Safari/537.36", + "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.90 Safari/537.36", + "Mozilla/5.0 (X11; NetBSD) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.116 Safari/537.36", + "Mozilla/5.0 (X11; CrOS i686 3912.101.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.116 Safari/537.36", + "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.60 Safari/537.17", + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1309.0 Safari/537.17", + "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.15 (KHTML, like Gecko) Chrome/24.0.1295.0 Safari/537.15", + "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.14 (KHTML, like Gecko) Chrome/24.0.1292.0 Safari/537.14" + ] + + +def parse_json(s): + begin = s.find('{') + end = s.rfind('}') + 1 + return json.loads(s[begin:end]) + + +def get_random_useragent(): + """生成随机的UserAgent + :return: UserAgent字符串 + """ + return random.choice(USER_AGENTS) + + +def wait_some_time(): + time.sleep(random.randint(100, 300) / 1000) + + +def send_wechat(message): + """推送信息到微信""" + url = 'http://sc.ftqq.com/{}.send'.format(global_config.getRaw('messenger', 'sckey')) + payload = { + "text":'抢购结果', + "desp": message + } + headers = { + 'User-Agent':global_config.getRaw('config', 'DEFAULT_USER_AGENT') + } + requests.get(url, params=payload, headers=headers) + + +def response_status(resp): + if resp.status_code != requests.codes.OK: + print('Status: %u, Url: %s' % (resp.status_code, resp.url)) + return False + return True + + +def open_image(image_file): + if os.name == "nt": + os.system('start ' + image_file) # for Windows + else: + if os.uname()[0] == "Linux": + if "deepin" in os.uname()[2]: + os.system("deepin-image-viewer " + image_file) # for deepin + else: + os.system("eog " + image_file) # for Linux + else: + os.system("open " + image_file) # for Mac + + +def save_image(resp, image_file): + with open(image_file, 'wb') as f: + for chunk in resp.iter_content(chunk_size=1024): + f.write(chunk)