Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
pip install cd-parser
pip install -U cd-parser
A utility class for commonly used regex operations in Python.
Here are some example usages of the RegexParser
class:
from cd_parser import regex
# Replace text
modified_text = regex.replace("old", "new", "This is an old text.")
print(modified_text) # Output: "This is a new text."
# Find all matches
matches = regex.find_all("[A-Za-z]+", "123 apple 456 banana")
print(matches) # Output: ['apple', 'banana']
# ... [You can add more examples for other methods]
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Absolutely. Here's a README.md file for the XpathParser
class:
A simple and lightweight XPath parser class for extracting data from HTML/XML content. Built on top of the lxml
library, it offers a variety of methods for precise element extraction based on various criteria.
Create an instance of the XpathParser
class with your HTML/XML content:
from cd_parser import XpathParser
doc_text = """
<html>
<body>
<a id="link1" href="https://example.com/page1">Link 1</a>
<a id="link2" href="https://example.com/page2">Link 2</a>
</body>
</html>
"""
parser = XpathParser(doc_text)
Using custom XPath:
links = parser.get_elements('//a')
print([link.text for link in links])
Get a single element (the first match):
single_link = parser.get_element('//*[@id="link1"]')
if single_link:
print(single_link.text)
Select all nodes:
all_nodes = parser.select_all_nodes()
Select by tag:
anchors = parser.select_by_tag("a")
Select by attribute:
divs_with_class = parser.select_by_class("div", "my-class")
... and many more. Refer to the class docstrings for details on each method.
from cd_parser import clipboard as cb
text = cb.copy("text you want to copy")
print(cb.paste())
Feel free to fork the repository, make your changes, and submit pull requests. We appreciate all contributions!
Please note:
xpath_parser.py
is assumed in the usage example. Adjust it accordingly if you're using a different filename.License
MIT License
More documentation at: Code Docta
FAQs
Text manipulation with Xpath, Regex and clipboard actions.
We found that cd-parser demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.