Skip to content

Commit

Permalink
release 0.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
JarbasAl committed Dec 13, 2019
1 parent 807a5b4 commit f1d2a32
Show file tree
Hide file tree
Showing 9 changed files with 305 additions and 170 deletions.
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,30 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.5.0] - 2019-12-12

Breaking Changes, api is backward incompatible

### Changed

- Refactor into individual classes
- WikiHow
- HowTo
- HowToStep
- Refactor search
- WikiHow.search is now a generator
- search now returns HowTo objects instead of urls
- split examples in several files

### Added

- search_wikihow function
- ParseError exception

### Fixed

- handle parse errors

## [0.3.1] - 2019-12-12

### Changed
Expand All @@ -15,4 +39,5 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Made a changelog

[unreleased]: https://github.com/OpenJarbas/PyWikiHow/tree/dev
[0.5.0]: https://github.com/OpenJarbas/PyWikiHow/tree/0.5.0
[0.3.1]: https://github.com/OpenJarbas/PyWikiHow/tree/0.3.1
73 changes: 54 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,72 @@

unofficial wikihow python api

- [PyWikiHow](#pywikihow)
* [Install](#install)
* [Usage](#usage)
+ [Random How To](#random-how-to)
+ [Searching](#searching)
+ [Parsing](#parsing)


## Install
```bash
pip install pywikihow
```

## Usage

### Random How To

Learn random stuff!

```python
from pywikihow import WikiHow
from pywikihow import RandomHowTo

# get a random how to
random_how_to = WikiHow.random()
how_to = RandomHowTo()
how_to.print()

# search wikihow pages
urls = WikiHow.search("buy bitcoin")
```

# parse a specific page
title, steps, ex_steps, pic_links, url = WikiHow.parse("https://www.wikihow.com/Train-a-Dog")
### Searching

# search how to X
results = WikiHow.how_to("boil an egg")
```python
from pywikihow import WikiHow, search_wikihow

# navigate results
for how_to in results:
data = results[how_to]
title = data["title"]
url = data["url"]
steps = data["steps"]
for step in steps:
text = step["step"]
extended_description = step["detailed"]
picture = step["pic"]

max_results = 1 # default for optional argument is 10
how_tos = search_wikihow("how to learn programming", max_results)
assert len(how_tos) == 1
how_tos[0].print()


# for efficiency and to get unlimited entries, the best is to use the generator
for how_to in WikiHow.search("how to learn python"):
how_to.print()

```

### Parsing

Manipulate HowTo objects

```python
from pywikihow import HowTo

how_to = HowTo("https://www.wikihow.com/Train-a-Dog")

data = how_to.as_dict()

print(how_to.url)
print(how_to.title)
print(how_to.n_steps)
print(how_to.summary)

first_step = how_to.steps[0]
first_step.print()
data = first_step.as_dict()

how_to.print(extended=True)

```

16 changes: 16 additions & 0 deletions examples/how_to_url.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from pywikihow import HowTo

how_to = HowTo("https://www.wikihow.com/Train-a-Dog")

data = how_to.as_dict()

print(how_to.url)
print(how_to.title)
print(how_to.n_steps)
print(how_to.summary)

first_step = how_to.steps[0]
first_step.print()
data = first_step.as_dict()

how_to.print(extended=True)
24 changes: 0 additions & 24 deletions examples/quick_start.py

This file was deleted.

4 changes: 4 additions & 0 deletions examples/random_how_to.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from pywikihow import RandomHowTo

how_to = RandomHowTo()
how_to.print()
12 changes: 12 additions & 0 deletions examples/search.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from pywikihow import WikiHow, search_wikihow


max_results = 1 # default for optional argument is 10
how_tos = search_wikihow("how to learn programming", max_results)
assert len(how_tos) == 1
how_tos[0].print()


# for efficiency and to get unlimited entries, the best is to use the generator
for how_to in WikiHow.search("how to learn python"):
how_to.print()
Loading

0 comments on commit f1d2a32

Please sign in to comment.