Skip to content

Commit 3169995

Browse files
Improved readability and consistency.
1 parent b97a53e commit 3169995

2 files changed

Lines changed: 58 additions & 73 deletions

File tree

README.md

Lines changed: 56 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
![Python](https://img.shields.io/badge/python-v3.9+-blue.svg)
44
![License](https://img.shields.io/badge/license-MIT-green.svg)
5-
![Dependencies](https://img.shields.io/badge/dependencies-requests%20%3E%3D%202.32.0-orange)
5+
![Dependencies](https://img.shields.io/badge/dependencies-1-brightgreen)
66

77
## Table of Contents
88
- [Text and Data Mining (TDM)](#text-and-data-mining-tdm)
@@ -14,8 +14,8 @@
1414
- [Install](#install)
1515
- [Basic Usage](#basic-usage)
1616
- [Troubleshooting](#troubleshooting)
17+
- [Installation](#installation)
1718
- [Access denied](#access-denied)
18-
- [Installation Issues](#installation-issues)
1919
- [Contributing](#contributing)
2020
- [License](#license)
2121

@@ -29,50 +29,51 @@ The Wiley TDM Client is a Python package (installable via pip) that aims to simp
2929

3030
## Features
3131

32-
The Wiley TDM Client has the following capabilities
32+
The Wiley TDM Client has the following capabilities:
3333

3434
* **PDF Downloads** - Download PDFs from Wiley's TDM API
35-
* Single or bulk DOI downloads (DOIs from file)
35+
* Single or bulk PDF downloads
3636
* Configurable download directory
3737
* Automatic DOI-based file naming
3838
* **DOI Validation**
39-
* Non-Wiley DOI detection (via CrossRef API)
40-
* Invalid DOIs
41-
* DOI encoding
39+
* Wiley DOI verification
40+
* Invalid DOI detection
41+
* DOI URL encoding
4242
* **API Handling**
43-
* Authentication (API Token & IP)
43+
* Authentication (API token & IP based auth)
4444
* Rate limiting support
4545
* Error handling (e.g. Access denied)
4646
* **Reporting**
4747
* CSV export of download results
48-
* Download statistics (success/failure rates)
48+
* API status
4949
* File sizes and download durations
5050
* **Efficiency**
5151
* API Session handling
52-
* Low memory utilisation with PDF streaming
52+
* Low memory utilization with PDF streaming
5353
* Graceful timeouts
5454

5555
## Requirements
5656

5757
You will require the following:
5858

5959
* A [Python 3.9+](https://www.python.org/downloads/) environment
60-
* Python packages:
61-
* requests>=2.32.0
60+
* Python dependencies:
61+
* [requests](https://requests.readthedocs.io/) (≥2.32.0)
6262
* A [Wiley Online Library](https://onlinelibrary.wiley.com/) (WOL) Account
6363
* A TDM API Token, available from the WOL [TDM resources page](https://onlinelibrary.wiley.com/library-info/resources/text-and-datamining) using your WOL Account
6464
* Access to the content you wish to download
65-
* Access will be determined via your IP address
65+
* Access will be determined via your [public IP address](https://api.ipify.org/?format=json)
6666

6767
## Quick Start
6868

6969
### Environment Variables
7070

7171
Set the environment variable `TDM_API_TOKEN` to your API token:
7272

73+
Linux example
7374
```bash
7475
# Set your TDM API token (required)
75-
export TDM_API_TOKEN='your-tdm-api-token'
76+
export TDM_API_TOKEN='your-api-token-here'
7677
echo $TDM_API_TOKEN
7778
```
7879

@@ -90,57 +91,70 @@ source venv/bin/activate
9091

9192
# Verify installation
9293
(venv) $ pip list | grep wiley-tdm
93-
94-
# Deactivate virtual environment (you can keep it open)
95-
(venv) $ deactivate
9694
```
9795

9896
### Basic Usage
9997

100-
The following example will download a single Open Access Article PDF to a 'downloads' folder,
101-
relative to your current working directory, and name the file `<doi>`.pdf.
102-
103-
Create example1.py (Copy or [download](examples/example1.py))
98+
The following examples will download Article PDFs to a 'downloads' directory,
99+
relative to your current working directory, and name the files `<doi>`.pdf. Run all code in your [Virtual Environment](#install).
104100

101+
**Instantiate client**
105102
```python
106-
import logging
107103
from wiley_tdm import TDMClient
108104

109-
# Setup logging
110-
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
111-
112105
# Initialize client (uses TDM_API_TOKEN from environment)
113106
tdm = TDMClient()
107+
```
114108

115-
# Download a single Article PDF
109+
**Download Single PDF**
110+
```python
116111
tdm.download_pdf('10.1111/jtsb.12390')
117112
```
118113

119-
Execute in your Virtual Environment (important) and observe the downloaded PDF:
114+
**Download Multiple PDFs**
115+
```python
116+
tdm.download_pdfs(["10.1111/jtsb.12390", "10.1111/jlse.12141"])
117+
```
120118

121-
```bash
122-
# Activate virtual environment
123-
source venv/bin/activate
119+
**More examples**
124120

125-
# Run example
126-
(venv) $ python3 example1.py
121+
See more [examples](examples/).
127122

128-
# List downloads
129-
(venv) $ ls -la downloads/
123+
## Troubleshooting
124+
125+
In most troubleshooting scenarios it can be helpful to generate a report:
130126

131-
# Deactivate when done
132-
(venv) $ deactivate
127+
```
128+
# Save the download results to a CSV file: 'results.csv'
129+
tdm.save_download_results()
133130
```
134131

135-
See more [examples](examples/).
132+
### Installation
136133

137-
## Troubleshooting
134+
If you encounter installation issues:
135+
136+
```bash
137+
# Ensure you're using Python 3.9+
138+
python3 --version
139+
140+
# Update pip to latest version
141+
python3 -m pip install --upgrade pip
142+
```
143+
144+
Alternatively, try installing a fresh [Virtual Environment](#install).
145+
146+
If problems persist, please [open an issue](https://github.com/WileyLabs/tdm-client/issues) with:
147+
- Your Python version
148+
- The exact error message
149+
- Your operating system details
138150

139151
### Access denied
140152

141-
Check you can manually view the desired content directly on [Wiley Online Library](https://onlinelibrary.wiley.com/).
153+
Check access directly on [Wiley Online Library](https://onlinelibrary.wiley.com/).
154+
- If access denied: contact your Institution/Wiley and check your subscription is active.
155+
- If access granted: ensure you are accessing the TDM API from a known IP address (see below).
142156

143-
If you can, it is possible that the IP address you are accessing the website from is different to where you are running your TDM code. Observe your IP address in the TDM console log and compare to the IP address in your [browser](https://api.ipify.org?format=json).
157+
It is possible that the IP address you are accessing WOL from is different to where you are running your TDM code. Observe your IP address in the TDM console log and compare to the IP address in your [browser](https://api.ipify.org?format=json).
144158

145159
Example console output:
146160
```
@@ -151,45 +165,16 @@ Example Browser output:
151165

152166
```json
153167
// https://api.ipify.org/?format=json
154-
155168
{
156169
"ip": "XX.XX.XX.XX"
157170
}
158171
```
159172

160-
### Installation Issues
161-
162-
If you encounter issues during installation, ensure you have the correct version of Python and the required packages. You can also try reinstalling the package:
163-
164-
```bash
165-
# Activate virtual environment
166-
source venv/bin/activate
167-
168-
# Uninstall package
169-
(venv) $ pip uninstall wiley-tdm
170-
171-
# Install package
172-
(venv) $ pip install wiley-tdm
173-
174-
# Verify installation
175-
(venv) $ pip list | grep wiley-tdm
176-
177-
# Deactivate virtual environment
178-
(venv) $ deactivate
179-
```
173+
If problems persist, please contact: tdm@wiley.com
180174

181175
## Contributing
182176

183-
We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details on how to:
184-
185-
- Set up your development environment
186-
- Run tests
187-
- Submit pull requests
188-
189-
Please ensure your PR includes:
190-
- Clear description of changes
191-
- Updated documentation
192-
- Test cases if applicable
177+
We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for further details.
193178

194179
## License
195180

examples/example3.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
1313
Output:
1414
- downloads/oa-pdfs/<doi>.pdf: Downloaded PDF files
15-
- downloads/oa-pdfs/download_results.csv: Download status report
15+
- results.csv: Download status report
1616
"""
1717

1818
import logging
@@ -31,5 +31,5 @@
3131
# Download multiple Article PDFs, listed in a file, to the 'downloads/oa-pdfs' folder
3232
tdm.download_pdfs_from_file("oa-dois.txt")
3333

34-
# Save the download results to a CSV file: 'downloads/oa-pdfs/download_results.csv'
34+
# Save the download results to a CSV file: 'results.csv'
3535
tdm.save_download_results()

0 commit comments

Comments
 (0)