Skip to content

Generate Xpath list after giving tag, attribute and attribute' value.

License

Notifications You must be signed in to change notification settings

Terryhung/Xpath_Generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Xpath_Generator

Generate Xpath list after giving tag, attribute and attribute' value.

Dependences

Install

  • With pip: pip install xpath_generator
  • With git:
    1. git clone https://github.com/Terryhung/Xpath_Generator.git
    2. pip install -r requirements.txt

Usage

from xpath_generator.xpath_generator import XpathGEN

url = 'https://guides.github.com/activities/hello-world/'

element = {
    'tag': 'a',
    'attr': 'id',
    'attr_value': 'intro'
}

headers = {
    'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4)\
    AppleWebKit/537.36 (KHTML, like Gecko) \
    Chrome/58.0.3029.96 Safari/537.36'
}

# default parent_layers is 5
xpath_gen = XpathGEN(url, element, parent_layers=3, headers=headers)
xpaths = xpath_gen.get_xpaths()

Return Value:

{
  'xpaths': 
    [
      '//div[@class="wrap"]/div[@class="markdown-body content-body "]/p/a[@id="intro"]'
    ]
}

About

Generate Xpath list after giving tag, attribute and attribute' value.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages