Get the App
SLTechnology News&Howtos  ›  Development  › 

How to identify the owner of a building by Python regular expression

Shulou Source: shulou.com Published: 2022-06-02 23:36:14 10月04日 Update

This article is about how to use Python regular expressions to identify landlords. The editor thinks it is very practical, so I share it with you. I hope you can get something after reading this article.

Identify the owner of the building:

Post code snippet:

Var chrType = "public"; var intAuthorId = ""; var chrAuthorName = "GreyHouse"; var chrTitle = "[light and shadow record] flea's trip to Europe"; var chrItem = 'travel'; var intItem =' 0mm; var intArticleId = "191157"; var tAuthor = 'GreyHouse'

Use the following Python regular expression to find the landlord:

Rereg_louzhu = re.compile ('. * chrAuthorName = "(. *?)";'

Set mat to reg_louzhu.match (html line of the source code of the web page), then mat.groups () [0] is the main name of the building GreyHouse

Identify the starting position of a post

Continue to analyze html and find that Tianya replies generally use the author information bar as the beginning of the post, so the end of the post is before the next author information bar.

Author: shopping in a tank

The above is how to use Python regular expression to identify the landlord. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Tags: Landlord post regular expression author information tank that is more knowledge article start utility code location light and shadow name reply Tianya tail Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia Huawei Apple MariaDB Xiaomi