Comments (5)
How I solved this issue: just grabbed the body of the page with axios and with regex found the normal url which then can be processed by ogs. This is a good example of middleware function.
from opengraphscraper.
@d-ivashchuk Great idea Dimitri, I will try it out as soon as I can get to it. Great idea though thanks!
from opengraphscraper.
Experiencing the same issue! Probably because as already pointed out itโs a mirrored link and not the final link.
@hamedb89 Were you able to solve it?
I would appreciate clarification for this one, as I saw that it should work with redirects, however medium is for sure not working!
Thanks a lot๐๐ผ
from opengraphscraper.
Hello,
I started digging into this. openGraphScraper
uses the request library to make http requests and one of the options that I use is followAllRedirects
, which should follow all of the redirects.
request docs: https://github.com/request/request#requestoptions-callback
Unfortunately this is the page I get when using request:
<html>
<body>
<script type="text/javascript">
function unescapeHtml(escaped_str) {
var div = document.createElement('div');
div.innerHTML = escaped_str;
var child = div.childNodes[0];
return child ? child.nodeValue : null;
}
function validateProtocol(url) {
var parser = document.createElement('a');
parser.href = url;
var protocol = parser.protocol.toLowerCase();
if ([ 'javascript:', 'vbscript:', 'data:', 'ftp:',':' , ' '].indexOf(protocol) < 0) {
return url;
}
return null;
}
function validate(url) {
var unescaped_value = unescapeHtml(url);
if (unescaped_value && validateProtocol(unescaped_value)) {
return unescaped_value;
}
return '/';
} var hasURI = false;
var intervalExecuted = false;
window.onload = function() {
document.getElementById("l").src = validate("null/p/17dc61071ed5?link_click_id=656998272080551846");
window.setTimeout(function() {
if (!hasURI) {
window.top.location = validate("https://medium.com/@racheltho/techs-long-hours-are-discriminatory-counter-productive-17dc61071ed5?source=linkShare-5037b396cb47-1550350532&_branch_match_id=656998272080551846");
}
intervalExecuted = true;
}, 300);
};
window.onblur = function() {
hasURI = true;
};
window.onfocus = function() {
if (hasURI) {
window.top.location = validate("https://medium.com/@racheltho/techs-long-hours-are-discriminatory-counter-productive-17dc61071ed5?source=linkShare-5037b396cb47-1550350532&_branch_match_id=656998272080551846");
} else if(intervalExecuted) {
window.top.location = validate("https://medium.com/@racheltho/techs-long-hours-are-discriminatory-counter-productive-17dc61071ed5?source=linkShare-5037b396cb47-1550350532&_branch_match_id=656998272080551846");
}
}
</script>
<iframe id="l" width="1" height="1" style="visibility:hidden"></iframe>
</body>
</html>
Request can't run javascript, so there is no way of getting to the final page. To get this to work I would have to rewrite openGraphScraper
to use headless chrome or something like that.
from opengraphscraper.
Yes, using the html
option in ogs is great way to solve this problem. Closing the issue.
from opengraphscraper.
Related Issues (20)
- Module not found: Can't resolve 'http2' HOT 1
- reuslt.twitterImage is improperly typed as string | undefined HOT 3
- open-graph-scraper > 4.11.1 jest and supertest segfault HOT 3
- Cannot find module './lib/openGraphScraper' or its corresponding type declarations HOT 3
- TS Error: Cannot find module './lib/openGraphScraper' HOT 3
- Something is not right with the types HOT 4
- Type error in index.ts HOT 1
- Missing got dependency HOT 2
- Types Errors HOT 6
- Can the library keyv be replaced with something else? HOT 3
- fetchOptions type HOT 1
- Regression: Fetching `https://facebook.com` yields no image HOT 5
- Lower Node 18 requirement HOT 1
- Problem with specifying the html option in TypeScript HOT 1
- Why the error with a generic 400/500 error message? HOT 2
- Twitter / X.com Open graph tags not working anymore HOT 4
- It is better to export SuccessResult and ErrorResult types HOT 2
- Fail to detect charset from certain ShiftJIS page HOT 10
- Add Support for Edge Functions HOT 2
- Support title & description fields HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from opengraphscraper.